等同于:
oncomplete = update="mydatatable"
如果我使用的是openssl _ *?
openssl_digest不带$ key参数。
答案 0 :(得分:1)
此函数使用openssl_ *扩展来散列数据和密钥:
function openssl_hmac($algo, $data, $key, $raw_output = false)
{
$algo = strtolower($algo);
$pack = 'H' . strlen(openssl_digest('test', $algo));
$size = 64;
$opad = str_repeat(chr(0x5C), $size);
$ipad = str_repeat(chr(0x36), $size);
if (strlen($key) > $size) {
$key = str_pad(pack($pack, $algo($key)), $size, chr(0x00));
} else {
$key = str_pad($key, $size, chr(0x00));
}
for ($i = 0; $i < strlen($key) - 1; $i++) {
$opad[$i] = $opad[$i] ^ $key[$i];
$ipad[$i] = $ipad[$i] ^ $key[$i];
}
$output = openssl_digest($opad . pack($pack, openssl_digest($ipad . $data, $algo)), $algo);
return ($raw_output) ? pack($pack, $output) : $output;
}
echo openssl_hmac('sha256', 'data', 'key', false);
结果:
5031fe3d989c6d1537a013fa6e739da23463fdaec3b70137d828e36ace221bd0
结果与使用hash_hmac
函数时的结果相同:
echo hash_hmac('sha256', 'data', 'key');
结果:
5031fe3d989c6d1537a013fa6e739da23463fdaec3b70137d828e36ace221bd0