PHP encryption 3DES error call to undefined Function:mcrypt_module_open () How to fix, mcryptmoduleopen_php tutorial

Source: Internet
Author: User
Tags crypt

PHP encryption 3DES error call to undefined Function:mcrypt_module_open () How to solve, 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 version 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**/class crypt3des{Public $key = "01234567890123456789012345678912";p ublic $iv = "23456789";//like java:private S Tatic byte[] Myiv = {50, 51, 52, 53, 54, 55, 56, 57};//Encrypt public Function encrypt ($input) {$input = $this->padding ($in Put), $key = Base64_decode ($this->key), $td = Mcrypt_module_open (Mcrypt_3des, ", MCRYPT_MODE_CBC,");//Use Mcrypt_ 3DES algorithm, CBC mode Mcrypt_generic_init ($TD, $key, $this->iv);//initial processing $data = Mcrypt_generic ($TD, $input);//Encryption Mcrypt_ Generic_deinit ($TD);//End Mcrypt_module_close ($TD), $data = $this->removebr (Base64_encode ($data)); return $data;} Decrypt public Function decrypt ($encrypted) {$encrypted = Base64_decode ($encrypted); $key = Base64_decode ($this->key); $ td = Mcrypt_module_open (Mcrypt_3des, ' ', MCRYPT_MODE_CBC, ');//using mcrypt_3des algorithm, CBC mode Mcrypt_generic_init ($TD, $key, $ THIS-&GT;IV);//initial processing $decrypted = Mdecrypt_generic ($TD, $encrypted);//decryption Mcrypt_generic_deinit ($TD);//End Mcrypt_module_close ($TD); $decrypted = $this->removepadding ($decrypted); return $decrypted;} Fill password, padding to multiples of 8 public function padding ($str) {$len = 8-strlen ($str)% 8;for ($i = 0; $i < $len; $i + +) {$str. = Chr (0);} return $STR;} Delete shim public Function removepadding ($str) {$len = strlen ($str), $newstr = ""; $str = Str_split ($STR); for ($i = 0; $i < $len; $i + +) {if ($str [$i]! = Chr (0)) {$newstr. = $str [$i];}} return $NEWSTR;} Delete carriage return and newline public function Removebr ($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 = new Crypt3des (); 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/1122181.html www.bkjia.com true http://www.bkjia.com/PHPjc/1122181.html techarticle PHP Encryption 3DES error call to undefined Function:mcrypt_module_open () How to solve, mcryptmoduleopen I am also a novice php, After understanding the basic principles of PHP after w3cschool to write ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.