janjanenjoy / crypt
明文传输:数据签名/验签、密文传输:数据加/解密
1.5
2020-03-22 03:38 UTC
Requires
- php: >=7.1.3
- ext-json: *
- ext-mbstring: *
- ext-openssl: *
- illuminate/container: ^5.1
README
Installing
composer require janjanenjoy/crypt
Laravel
register the provider to your project
//config/app.php 'providers' => [ //... JanjanEnjoy\Crypt\CryptServiceProvider::class, //This is default in laravel 5.5 ], /**if you want to use Facade mode ,you can add your own alias configuration like below.**/ 'aliases' => [ //... 'MyCrypt' => \JanjanEnjoy\Crypt\CryptService::class, ]
and publish the config file to your project or copy the file from vendor by manual operation.
php artisan vendor:publish --provider=JanjanEnjoy\\Crypt\\CryptServiceProvider
lumen
register the provider to your project
//bootstrap/app.php $app->register( JanjanEnjoy\Crypt\CryptServiceProvider::class);
copy the config file from vendor to your root config direction by manual operation
Configuration
/** * 本项目的app_secret */ 'app_secret' =>env('XTHK_APP_SECRET','12345678912345678912345678912312'), /** * 加密规则,支持AES-128-CBC,AES-256-CBC */ 'cipher' => env('XTHK_CIPHER','AES-256-CBC'),
Usage
$data = ['test'=>123]; $sign = MingCrypt::sign($data); //签名 print_r($sign); $check = MingCrypt::signCheck($data,$sign); //验签 print_r($check);