Home >Backend Development >PHP Tutorial >PHP adjustment interface Sign verification
This article mainly introduces the verification of the PHP adjustment interface Sign. It has a certain reference value. Now I share it with everyone. Friends in need can refer to it.
<?php namespace App\Librarys; class SignUtil{ /** * @param array $params * @return string */ public static function getCheckSign($params) { $arrSign = []; ksort($params); $ts = $params['ts']; $token = '8553d751250eb0846e84d67b6bdf250f'; foreach ($params as $k => $v) { if ($k == 'sign' || $k == 'ts') { continue; } if (is_array($v)) { $v = json_encode($v); } $strTmp = trim($k) . '=' . trim($v); $arrSign[$strTmp] = $strTmp; } $strSign = implode('&', $arrSign); $sign = md5($strSign.$ts.$token); return $sign; } }
$params = $request->all(); if(!isset($params['sign'])){ return $this->failsmsg('缺少sign校验参数'); } $mySign = SignUtil::getCheckSign($params); if($params['sign'] != $mySign){ return $this->failsmsg('sign校验失败'); }
The above is the entire article. Content, please pay attention to the PHP Chinese website for more related content.
Related recommendations:
Detailed explanation of SQLite PHP interface
The meaning of interface in php interface
The above is the detailed content of PHP adjustment interface Sign verification. For more information, please follow other related articles on the PHP Chinese website!