PHP code example of shaozeming / laravel-crypt

1. Go to this page and download the library: Download shaozeming/laravel-crypt library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

shaozeming / laravel-crypt example snippets


// config/app.php

    'providers' => [
        //...
        ShaoZeMing\LaravelCrypt\CryptServiceProvider::class,    //This is default in laravel 5.5
    ],

// config/app.php

    'aliases' => [
        'MingCrypt' => ShaoZeMing\LaravelCrypt\Facade\Crypt::class,   //This is default in laravel 5.5
    ],

// 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'),



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);

shell
$ php artisan vendor:publish --provider=ShaoZeMing\\LaravelCrypt\\CryptServiceProvider