mhash() - mhash库(加密)
mhash()
(PHP 4, PHP 5, PHP 7)
Computes hash
说明
mhash(int $hash,string $data[,string $key]): stringmhash() applies a hash function specified by$hashto the$data.
参数
$hash The hash ID. One of the MHASH_hashname
constants.
The user input, as a string.
$keyIf specified, the function will return the resulting HMAC instead. HMAC is keyed hashing for message authentication, or simply a message digest that depends on the specified key. Not all algorithms supported in mhash can be used in HMAC mode.
返回值
Returns the resulting hash(also called digest)or HMAC as a string, or FALSE
on error.
Want to Create a md5 HMAC, but don't have hmash installed? Use this: 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))); } ----- To test: Run this on a server _with_ mhash installed: $key = 'Jefe'; $data = "what do ya want for nothing?"; echo hmac($key, $data); echo "<br>\n"; echo bin2hex (mhash(MHASH_MD5, $data, $key)); should produce: 750c783e6ab0b503eaa86e310a5db738 750c783e6ab0b503eaa86e310a5db738 Happy hashing.
Here is how to compute a NTLM hash:
鹏仔微信 15129739599 鹏仔QQ344225443 鹏仔前端 pjxi.com 共享博客 sharedbk.com
图片声明:本站部分配图来自网络。本站只作为美观性配图使用,无任何非法侵犯第三方意图,一切解释权归图片著作权方,本站不承担任何责任。如有恶意碰瓷者,必当奉陪到底严惩不贷!