This article describes the PHP implementation of an enhanced Mhash function code, with the need for a friend reference. In the program used PHP cryptographic function Mhash, error: Fatal error:call to undefined function mhash () The following two workarounds are available for reference. 1, import the Php_mhash.dll extension file, in addition to import Libmhash.dll (Mhash library load dependent on this file), in the Apache configuration file httpd.conf loaded LoadFile c:/php/ Libmhash.dll ". 2, using the custom Mhash enhancement function. !--? php/*** custom Mhash enhancement function * Edit by Bbs.it-home.org*/function hmac_ MD5 ($key, $data) {if (extension_loaded (' Mhash ')) {return Bin2Hex (Mhash (MHASH_MD5, $data, $key)); } $b = 64; 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));}? Code Description: The Parameters $key and $data in the HMAC_MD5 function correspond mhash the original 3,2 parameters. Both of these methods can use PHP's Mhash encryption function smoothly. |