Re: [徵求] PHP5 > function mhash()
※ 引述《tirme (Tirme)》之銘言:
: 我在網路上看有人說PHP5不支援mhash
: 我使用PHP5.2.1版(appserv2.5.7 win32)
: 解開php.ini的extension=php_mhash.dll 並且restart了
: 但是仍然無法找到function mhash()
: 請問有辦法解決嗎?
: 感謝幫忙
php官方就有人有寫好的函式可以用了 ~~
function hmac ($key, $data)
{
// RFC 2104 HMAC implementation for php.
// Creates an md5 HMAC.
// Eliminates the need to install mhash to compute a HMAC
// Hacked by Lance Rushing
$b = 64; // byte length for md5
if (strlen($key) > $b) {
$key = pack("H*",md5($key));
}
$key = str_pad($key, $b, chr(0x00));
$ipad = str_pad('', $b, chr(0x36));
$opad = str_pad('', $b, chr(0x5c));
$k_ipad = $key ^ $ipad ;
$k_opad = $key ^ $opad;
return md5($k_opad . pack("H*",md5($k_ipad . $data)));
}
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 220.132.101.76
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 2 之 2 篇):
PHP 近期熱門文章
PTT數位生活區 即時熱門文章