PHP encryption 3DES error call to undefined Function:mcrypt_module_open () workaround, Mcryptmoduleopen
I am also a novice php, through W3cschool to understand the basic principles of PHP after the write. But still rookie.
First, regardless of 3DES encryption method is right, methods are online, in the run time reported a mistake, the younger brother died. Find out and finally find out the way.
Php/** * php 3DES plus decryption class * * Can be compatible with Java 3DES (desede) encryption * * @Author: Luo Hui (Farmer.luo at gmail.com) * * @version: V0.1 2008.12.04 **/classcrypt3des{ Public $key= "01234567890123456789012345678912"; Public $iv= "23456789";//Like java:private static byte[] Myiv = {50, 51, 52, 53, 54, 55, 56, 57}; Encrypt Public functionEncrypt$input) { $input=$this->padding ($input ); $key=Base64_decode($this-Key); $TD= Mcrypt_module_open (Mcrypt_3des, ", MCRYPT_MODE_CBC,"); //using the mcrypt_3des algorithm, CBC modeMcrypt_generic_init ($TD,$key,$this-IV); //Initial processing $data= Mcrypt_generic ($TD,$input); //EncryptMcrypt_generic_deinit ($TD); //EndMcrypt_module_close ($TD); $data=$this->REMOVEBR (Base64_encode($data)); return $data; } //decryption Public functionDecrypt$encrypted) { $encrypted=Base64_decode($encrypted); $key=Base64_decode($this-Key); $TD= Mcrypt_module_open (Mcrypt_3des, ", MCRYPT_MODE_CBC,"); //using the mcrypt_3des algorithm, CBC modeMcrypt_generic_init ($TD,$key,$this-IV); //Initial processing $decrypted= Mdecrypt_generic ($TD,$encrypted); //decryptionMcrypt_generic_deinit ($TD); //EndMcrypt_module_close ($TD); $decrypted=$this->removepadding ($decrypted); return $decrypted; } //fill password, fill to multiples of 8 Public functionPadding$str ) { $len= 8-strlen($str)% 8; for($i= 0;$i<$len;$i++ ) { $str.=CHR* R ); } return $str ; } //Delete a fill character Public functionRemovepadding ($str ) { $len=strlen($str ); $newstr= ""; $str=Str_split($str); for($i= 0;$i<$len;$i++ ) { if($str[$i] !=CHR* R )) { $newstr.=$str[$i]; } } return $newstr; } //Remove carriage returns and line feeds Public functionREMOVEBR ($str ) { $len=strlen($str ); $newstr= ""; $str=Str_split($str); for($i= 0;$i<$len;$i++ ) { if($str[$i]! = ' \ n ' and$str[$i]! = ' \ r ') { $newstr.=$str[$i]; } } return $newstr; }}//Test$input= "1qaz2ws";Echo"PlainText:".$input."
";$crypt=Newcrypt3des ();Echo"Encode:".$crypt->encrypt ($input)."
";Echo"Decode:".$crypt->decrypt ($crypt->encrypt ($input));?>
Code can not look, just look inside a sentence: $td = Mcrypt_module_open (Mcrypt_3des, ", MCRYPT_MODE_CBC,"), the error is he.
I've searched for a whole bunch of solutions, and the right approach should be (for Windows systems only):
This error occurs when you use function Mcrypt_module_open to decrypt a server side that is running PHP that is missing libmcrypt.dll.
The following settings can be resolved on the server.
Download a PHP mcrypt module installation package on the Internet, only need to Libmcrypt.dll file (general website download, PHP directory already have)
1. Copy the Libmcrypt.dll to the System32 directory or the extensions directory under the PHP installation directory
2. Copy the Libmcrypt.dll to the bin directory of the Apache installation directory
3. Locate the php.ini file in the Windows directory , open it
4. Find; Directory in which the loadable Extensions (modules) reside.
Extension_dir = "./" such as: Extension_dir = "D:\php5\ext"
These two lines, to make Extension_dir point to the directory can find Libmcrypt.dll, or system path under the Libmcrypt.dll
5. Find; Windows Extensions entries below; Extension=php_mcrypt.dll this line and Extension=php_iconv.dll (my No, omitted) these two lines, remove the preceding semicolon
PS: Just start to look at the online solution, some said to modify the PHP installation directory under the php.ini, but after the modification is useless. Be sure to modify the php.ini! in the Windows directory
http://www.bkjia.com/PHPjc/1120376.html www.bkjia.com true http://www.bkjia.com/PHPjc/1120376.html techarticle PHP Encryption 3DES error call to undefined Function:mcrypt_module_open () solution, Mcryptmoduleopen I am also a novice php, After W3cschool understand the basic principles of PHP after the open ...