多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
[TOC] ## 使用 appkey 与 secretKey 参数验证 新建 `demo.php` 执行 `php -S 127.0.0.1:8081` ``` /*======= 加密 start =========*/ $appkey ="w12baqefaaoc"; $secretKey = "asjdKHKJHasjdIAHSdkASkdbaksjbdkjas"; $url ="http://127.0.0.1:8081/demo.php?"; $params['appkey'] = $appkey; $params['order_id']=1; $params['name']="idcpj"; $params['pwd']="123456"; $params['time']=time(); $params['sign'] = getSign($params,$secretKey); echo $url.http_build_query($params); function getSign($query,$secretKey){ ksort($query); $str = http_build_query($query); return md5($str.$secretKey); } /*======= 加密 end =========*/ /*======= 解密 start =========*/ $conf['w12baqefaaoc']="asjdKHKJHasjdIAHSdkASkdbaksjbdkjas"; $getParams = $_GET; if (abs(time() - $getParams['time'])>=3){//使用 abs 更加安全 die("<br/> time out"); } if (valiSign($getParams,$conf)){ die("<br/>succ"); }else{ die("<br/>error"); } function valiSign($params,$conf){ $paramsSign = $params['sign']; unset($params['sign']); ksort($params); $str = http_build_query($params); $cSign = md5($str.$conf[$params['appkey']]); return $paramsSign==$cSign; } /*======= 解密 end =========*/ ```