PHP code example of wen-gg / webman-api-sign

1. Go to this page and download the library: Download wen-gg/webman-api-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/ */

    

wen-gg / webman-api-sign example snippets


return [
    'enable' => true,

    //
    'driver' => \Wengg\WebmanApiSign\Driver\ArrayDriver::class, //如有需要可自行实现BaseDriver
    'encrypt' => 'sha256', //加密方式
    'timeout' => 60, //timestamp超时时间秒,0不限制
    'table' => 'app_sign', //表名

    //字段对照,可从(header,get,post)获取的值
    'fields' => [
        'app_key' => 'appKey', //app_key
        'timestamp' => 'timestamp', //时间戳
        'noncestr' => 'noncestr', //随机字符串
        'signature' => 'signature', //签名字符串
    ],

    //driver为ArrayDriver时生效,对应table
    'app_sign' => [
        [
            'app_key' => '1661408635', //应用key
            'app_secret' => 'D81668E7B3F24F4DAB32E5B88EAE27AC', //应用秘钥
            'app_name' => '默认', //应用名称
            'status' => 1, //状态:0=禁用,1=启用
            'expired_at' => null, //过期时间,例如:2023-01-01 00:00:00,null不限制
        ],
    ],
];

$signature = hash('sha256', 'a=1&appKey=1661408635&b[0]=你好世界&b[1]=abc123&c[d]=hello&noncestr=ewsqam&timestamp=1662721474D81668E7B3F24F4DAB32E5B88EAE27AC');