All Projects → liyu001989 → signature

liyu001989 / signature

Licence: MIT license
HMAC and RSA signature for Laravel and Lumen

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to signature

F License
Open Source License Key Generation and Verification Tool written in Go
Stars: ✭ 535 (+1957.69%)
Mutual labels:  rsa, hmac
webcrypto
A WebCrypto Polyfill for NodeJS
Stars: ✭ 111 (+326.92%)
Mutual labels:  rsa, hmac
Cryptography-Guidelines
Guidance on implementing cryptography as a developer.
Stars: ✭ 15 (-42.31%)
Mutual labels:  rsa, hmac
larsign
Laravel signature certification with web API server.
Stars: ✭ 18 (-30.77%)
Mutual labels:  signature, hmac
SolRsaVerify
Solidity RSA Sha256 Pkcs1 Verification
Stars: ✭ 45 (+73.08%)
Mutual labels:  signature, rsa
Auth Jwt
A demo to learn JWT by reverse engineering
Stars: ✭ 208 (+700%)
Mutual labels:  signature, rsa
Easyrsa
Simple and Secure Wrapper for phpseclib
Stars: ✭ 183 (+603.85%)
Mutual labels:  signature, rsa
Jsrsasign
The 'jsrsasign' (RSA-Sign JavaScript Library) is an opensource free cryptography library supporting RSA/RSAPSS/ECDSA/DSA signing/validation, ASN.1, PKCS#1/5/8 private/public key, X.509 certificate, CRL, OCSP, CMS SignedData, TimeStamp, CAdES JSON Web Signature/Token in pure JavaScript.
Stars: ✭ 2,760 (+10515.38%)
Mutual labels:  signature, rsa
pbkdf2-hmac-sha256
sha256, hmac with sha256 and pbkdf2 with hmac-sha256 in one header file
Stars: ✭ 19 (-26.92%)
Mutual labels:  hmac
eosdart ecc
Elliptic curve cryptography functions in Dart. Private Key, Public Key, Signature, AES, Encryption, Decryption
Stars: ✭ 25 (-3.85%)
Mutual labels:  signature
pandorabox
基于非对称加密(RSA)的私密信息传递工具,数据由本地客户端进行加密、解密操作。
Stars: ✭ 18 (-30.77%)
Mutual labels:  rsa
encryption
A simple wrapper for the OpenSSL Cipher library for Ruby and Rails applications. Distributed as a Gem through Rubygems.
Stars: ✭ 28 (+7.69%)
Mutual labels:  rsa
laravel-redis-sentinel-drivers
Redis Sentinel integration for Laravel and Lumen.
Stars: ✭ 100 (+284.62%)
Mutual labels:  lumen
enigma
A fast, native, cryptographic engine for the web
Stars: ✭ 101 (+288.46%)
Mutual labels:  rsa
rsa aes md5
RSA(SHA1withRSA/pem私钥0/crt证书公钥) + AES(256/AES/CBC/PKCS5Padding)
Stars: ✭ 11 (-57.69%)
Mutual labels:  rsa
cosign
Cooperative RSA signing
Stars: ✭ 25 (-3.85%)
Mutual labels:  rsa
mitome.in
Explore OpenPGP and other cryptography as an alternative for seals (mitome-in)
Stars: ✭ 30 (+15.38%)
Mutual labels:  signature
paper-wallet
stellar.github.io/paper-wallet/
Stars: ✭ 41 (+57.69%)
Mutual labels:  lumen
keystore-idb
In-browser key management with IndexedDB and the Web Crypto API
Stars: ✭ 37 (+42.31%)
Mutual labels:  rsa
oseid
Microchip AVR based smartcard/token with ECC and RSA cryptography
Stars: ✭ 17 (-34.62%)
Mutual labels:  rsa

Laravel signature

Use HMAC or RSA to sign data for Laravel and lumen;

Latest Stable Version Total Downloads StyleCI

Install

For Laravel < 5.5, please use the tag 0.2.10

laravel

composer require liyu/signature

lumen

  • bootstrap/app.php

      $app->register(Liyu\Signature\Facade\Signature::class);
    

config

  • you can use these in your ENV

      // default driver
      SIGNATURE_DRIVER
    
      // hmac algo and key
      SIGNATURE_HMAC_ALGO (default sha256)
      SIGNATURE_HMAC_KEY (default null)
    
      // rsa algo, public_key, private_key
      SIGNATURE_RSA_ALGO (default sha256)
      SIGNATURE_RSA_PUBLIC_KEY
      SIGNATURE_RSA_PRIVATE_KEY
    
  • if you want to use config

      laravel
      php artisan vendor:publish
    
      lumen
      copy vendor/liyu/signature/src/config/config.php config/signature.php
    

Usage

sign

$signature = Signature::sign('foobar');

$signature = Signature::setKey('foobar')->sign(['foo'=>'bar']);

$signature = Signature::signer('hmac')
    ->setAlgo('sha256')
    ->setKey('foobar')
    ->sign(['foo'=>'bar']);

$signature = Signature::signer('rsa')
    ->setPrivateKey('./private.pem')
    ->sign(['foo'=>'bar']);

verify

// true or false

Signature::verify($signature, 'foobar');

Signature::setKey('foobar')->verify($signature, ['foo'=>'bar']);

Signature::signer('hmac')
    ->setAlgo('sha256')
    ->setKey('foobar')
    ->verify($sign, ['foo'=>'bar']);

Signature::signer('rsa')
    ->setPublicKey('./public.pem')
    ->verify($signature, ['foo'=>'bar']);

Sign Steps

  • convert array data

      // origin
      $data = [
          'z' => 1,
          'a' => [
              'c' => 'c',
              'b' => 'b',
              'a' => [
                  'b' => 'b',
                  'a' => 'a'
              ]
          ],
      ];
    
      // ksort and convert to string
      $data = [
          'a' => [
              'a' => [
                  'a' => 'a'
                  'b' => 'b',
              ]
              'b' => 'b',
              'c' => 'c',
          ],
          'z' => '1',
      ];
    
      // json_encode
      {"a":{"a":{"a":"a","b":"b"},"b":"b","c":"c"},"z":"1"}
    
  • sign string。

      hmac  => hmac($algo, $convertData, $key);
      // outputs lowercase hexits
    
      rsa => base64_encode(openssl_sign_string);
    

License

MIT LICENSE

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].