PHP code example of bastphp / sign

1. Go to this page and download the library: Download bastphp/sign 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/ */

    

bastphp / sign example snippets

 



namespace App\Http\Controllers;

use Bastphp\Sign\SignClient;

class TestController extends Controller
{
    public function test()
    {
        $signObj = SignClient::client();//默认MD5做驱动
        $signObj->setAppId('123456');//设置加密的APPid
        $signObj->setKey('123123123');//设置加密的key
        $signObj->encode(['a'=>1,'b'=>2]);//生成签名
        //$sign = SignClient::client()->encode(['a'=>1,'b'=>2]);
        $sign = 'fb017403af19713cd9f94c21f2691803';
       $res = $signObj->verify(['a'=>1,'b'=>2],$sign);//验证签名
        
       var_dump($res);
    }

}