php des加密解密中出现Call to undefined function: mcrypt_get_iv_size(),mcrypt_create_iv()处理

$deskey = "12345678";

//Encrypt Function (编码)

function encrypt($encrypt) {
global $deskey;
$iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND);
$passcrypt = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $deskey, $encrypt, MCRYPT_MODE_ECB, $iv);
$encode = base64_encode($passcrypt);
return $encode;
}

//Decrypt Function (解码)
function decrypt($decrypt) {
global $deskey;
$decoded = base64_decode($decrypt);
$iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND);
$decrypted = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $deskey, $decoded, MCRYPT_MODE_ECB, $iv);
return $decrypted;
}

测试 test.php

echo encrypt("house201172217344028880728")."<br>";
 echo decrypt(encrypt("house201172217344028880728"));

出现啦Call to undefined function: mcrypt_get_iv_size() 解决方法为:copy libmcrypt.dll到window\system32目录 这个肯定没错

但还有重要的一点就是把PHP.ini中的;extension=php_mcrypt.dll  ;去掉及开启加密解密功能

个人测试没有把 libmcrypt.dll 拷贝到window\system32目录因为我的Apache  的httpd.conf配置中指定啦PHPIniDir "c:/php" PHP工作目录

你可能感兴趣的:(undefined)