shaozeming / laravel-crypt
一个签名/验签,加密解密的laravel/lumen包
Installs: 6 767
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- illuminate/container: >=5.1
- shaozeming/crypt: ^1.0
- vlucas/phpdotenv: >=3.0
Requires (Dev)
- mockery/mockery: ^0.9.9
- phpunit/phpunit: ^6.3
This package is auto-updated.
Last update: 2024-12-19 02:02:17 UTC
README
Installing
$ composer require shaozeming/laravel-crypt -v
Laravel
// 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 ],
lumen
- 在 bootstrap/app.php 中 82 行左右:
$app->register( ShaoZeMing\LaravelCrypt\CryptServiceProvider::class);
将 vendor/ShaoZeMing/laravel-crypt/config/crypt.php
拷贝到项目根目录/config
目录下,并将文件名改成crypt.php
。
configuration
// 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'),
Usage
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);
License
MIT