gpt4 book ai didi

php - fatal error : Call to undefined function mcrypt_get_iv_size() in AppServ

转载 作者:IT王子 更新时间:2023-10-28 23:48:44 24 4
gpt4 key购买 nike

我在通过 AppServ 使用 mcrypt_get_iv_size 函数时发现了一个问题.

我试图找到与解决问题相关的主题。

但是,我尝试将 libmcrypt.dll 下载到 symtem32 中,并通过删除从 ;extension=php_mcrypt.dllextension=php_mcrypt.dll 的注释来编辑 php.ini .然后重启apache。

不幸的是,重新加载页面后才能看到修改后的结果。

还是报错

Fatal error: Call to undefined function mcrypt_get_iv_size() in C:\AppServ\www\folder\index.php on line 36

一个函数包含以下内容:

class Encryption {
var $skey = "SuPerEncKey2010"; // you can change it

public function safe_b64encode($string) {

$data = base64_encode($string);
$data = str_replace(array('+','/','='),array('-','_',''),$data);
return $data;
}

public function safe_b64decode($string) {
$data = str_replace(array('-','_'),array('+','/'),$string);
$mod4 = strlen($data) % 4;
if ($mod4) {
$data .= substr('====', $mod4);
}
return base64_decode($data);
}

public function encode($value){

if(!$value){return false;}
$text = $value;
$iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
$crypttext = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $this->skey, $text, MCRYPT_MODE_ECB, $iv);
return trim($this->safe_b64encode($crypttext));
}

public function decode($value){

if(!$value){return false;}
$crypttext = $this->safe_b64decode($value);
$iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
$decrypttext = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $this->skey, $crypttext, MCRYPT_MODE_ECB, $iv);
return strtolower(trim($decrypttext));
}
}

最佳答案

在 Ubuntu 上,使用 PHP 5 和 Apache,你必须运行:

apt-get install php5-mcrypt
php5enmod mcrypt
service apache2 restart

如果您使用的是 PHP 7:

apt install php7.0-mcrypt

关于php - fatal error : Call to undefined function mcrypt_get_iv_size() in AppServ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27633584/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com