Example of encrypted string Sign
Example of encrypted string Sign (PHP):
All fields are sorted by key value and then encrypted by md5 twice, sign=md5(md5(“key1=value1&key2=value2&$key”)) The encryption key is spliced directly after the string.
function makeSign(array $sign_arr, string $m_key): string {
// Sort by key name in ascending order
ksort($sign_arr);
// Construct the query string uid=xxx&sid=xxx
$str = http_build_query($sign_arr);
// Splicing Key
$str .= $m_key;
// Double md5
return md5(md5($str));
}
// Usage Examples
$sign_arr = [
'uid' => $uid,
'sid' => $sid,
];
$m_key = "1234567890";
$sign = makeSign($sign_arr, $m_key);
echo $sign;