Implementation code of php enhanced mhash function

WBOY
Release: 2016-07-25 08:57:15
Original
849 people have browsed it
This article introduces the function code of an enhanced mhash implemented in PHP. Friends in need can refer to it.

The encryption function mhash of PHP is used in the program, and the error is reported: Fatal error: Call to undefined function mhash()

Two solutions are provided below for reference. 1. Import the php_mhash.dll extension file, and in addition, import libmhash.dll (the loading of the mhash library depends on this file), Load LoadFile C:/php/libmhash.dll in Apache’s configuration file Httpd.conf”.

2. Use custom mhash enhancement function.

 $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)));
}
?>
Copy after login

Code description: The parameters $key and $data in the hmac_md5 function correspond to the original 3,2 parameters of mhash. Both methods can successfully use PHP's mhash encryption function.



source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!