阿新 • • 發佈:2018-12-21
/** * 功能:加密方法 * @param string $params 加密字串 * @param string $appkey 加密鹽值 * @return string */ function checkSign($params, $appkey = 'JTIzQCV1RkYwMSV1ODA1QSV1NzBCOSV1NEU5MiV1NTJBOCV1RYwMUAlMjM=') { //header("Content-Type: text/html; charset=utf-8"); //AppKey 資訊,請替換 define('APPKEY', $appkey); //按照引數名排序 ksort($params); //字串常量 $codes = APPKEY; //連線待加密的字串 while (list($key, $val) = each($params)) { //\Think\Log::write('陣列日誌:key:'.$key . '--val:'.$val,'WARN'); //列印日誌 $codes .= ($key . $val); } //將字串sha1加密後,轉換為大寫 $data['sign'] = md5($codes); $data['codes'] = $codes; //$sign = strtoupper(sha1($codes)); return $data['sign']; }