Package Data | |
---|---|
Maintainer Username: | ShaoZeMing |
Maintainer Contact: | szm19920426@gmail.com (ShaoZeMing) |
Package Create Date: | 2019-07-05 |
Package Last Update: | 2020-03-18 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-26 15:05:29 |
Package Statistics | |
---|---|
Total Downloads: | 6,730 |
Monthly Downloads: | 74 |
Daily Downloads: | 5 |
Total Stars: | 0 |
Total Watchers: | 1 |
Total Forks: | 0 |
Total Open Issues: | 0 |
$ composer require shaozeming/laravel-crypt -v
// config/app.php
'providers' => [
//...
ShaoZeMing\LaravelCrypt\CryptServiceProvider::class, //This is default in laravel 5.5
],
And publish the config file:
$ php artisan vendor:publish --provider=ShaoZeMing\\LaravelCrypt\\CryptServiceProvider
if you want to use facade mode, you can register a facade name what you want to use, for example crypt
:
// config/app.php
'aliases' => [
'MingCrypt' => ShaoZeMing\LaravelCrypt\Facade\Crypt::class, //This is default in laravel 5.5
],
$app->register( ShaoZeMing\LaravelCrypt\CryptServiceProvider::class);
将 vendor/ShaoZeMing/laravel-crypt/config/crypt.php
拷贝到项目根目录/config
目录下,并将文件名改成crypt.php
。
// config/crypt.php
/**
* 本项目的app_secret
*/
'app_secret' =>env('XTHK_APP_SECRET','12345678912345678912345678912312'),
/**
* 加密规则,支持AES-128-CBC,AES-256-CBC
*/
'cipher' => env('XTHK_CIPHER','AES-256-CBC'),
Example:
use ShaoZeMing\LaravelCrypt\Facade\Crypt;
$data = ['test'=>123];
$sign = Crypt::sign($data); //签名
print_r($sign);
$check = Crypt::signCheck($data,$sign); //验签
print_r($check);
$payload = Crypt::encrypt($data); //加密
print_r($payload);
$data = Crypt::decrypt($payload); //解密
print_r($data);
MIT