-
2021-04-29 09:42:43
http://stackoverflow.com/questions/17109818/install-php-mcrypt-on-centos-6
问题:Call to undefined function mcrypt_get_block_size()
需要安装php的 myrypt扩展
解决方案:
1.
yum update
yum install php-mcrypt*
添加 extension=/usr/lib64/php/modules/mcrypt.so到php.ini
2.
PHP Warning: PHP Startup: mcrypt: Unable to initialize module
Module compiled with module API=20100525
PHP compiled with module API=20121212
These options need to match
in Unknown on line 0
rpm-Uvhhttp://mirror.webtatic.com/yum/el6/latest.rpmyum update
yum install php55w-mcrypt
重启php
更多相关内容 -
php7报错Function mcrypt_get_block_size() is deprecated
2021-03-24 19:37:46php7报错Function ...mcrypt_get_block_size — 获得加密算法的分组大小 Warning This function has been DEPRECATED as of PHP 7.1.0. Relying on this function is highly discouraged. 在php7中需要openssl替代php7报错Function mcrypt_get_block_size is deprecated
解决方案
mcrypt十年过去,现在php7+中已经开始淘汰。官方给出掉提示:
mcrypt_get_block_size — 获得加密算法的分组大小Warning This function has been DEPRECATED as of PHP 7.1.0. Relying on this function is highly discouraged.
在php7中需要openssl替代,这里需要注意的是:
在mcrypt中对加密key长度没有限制要求,传入多少长度都会参加加密,但是在openssl_encrypt中。key长度只能是16长度,>16长度后,签名结果保持不变,这里是哥坑,在替代方案测试时候容易出错,具体直接上代码对比
-
PHP7.2中AES加密解密方法mcrypt_module_open()替换方案 Function mcrypt_get_block_size() is deprecated
2021-04-22 11:29:39$pad = $blocksize - ($len % $blocksize); $string .= str_repeat(chr($pad), $pad); return $string; } private function strippadding($string) { $slast = ord(substr($string, -1)); $slastc = chr($slast); $...class Aes {
private $hex_iv = '00000000000000000000000000000000'; # converted JAVA byte code in to HEX and placed it here
private $key = '397e2eb61307109f6e68006ebcb62f98'; #Same as in JAVA
function __construct($key) {
$this->key = $key;
$this->key = hash('sha256', $this->key, true);
}
/*
function encrypt($str) {
$td = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', MCRYPT_MODE_CBC, '');
mcrypt_generic_init($td, $this->key, $this->hexToStr($this->hex_iv));
$block = mcrypt_get_block_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC);
$pad = $block - (strlen($str) % $block);
$str .= str_repeat(chr($pad), $pad);
$encrypted = mcrypt_generic($td, $str);
mcrypt_generic_deinit($td);
mcrypt_module_close($td);
return base64_encode($encrypted);
}
function decrypt($code) {
$td = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', MCRYPT_MODE_CBC, '');
mcrypt_generic_init($td, $this->key, $this->hexToStr($this->hex_iv));
$str = mdecrypt_generic($td, base64_decode($code));
$block = mcrypt_get_block_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC);
mcrypt_generic_deinit($td);
mcrypt_module_close($td);
return $this->strippadding($str);
}*/
public function encrypt($input)
{
$data = openssl_encrypt($input, 'AES-256-CBC', $this->key, OPENSSL_RAW_DATA, $this->hexToStr($this->hex_iv));
$data = base64_encode($data);
return $data;
}
public function decrypt($input)
{
$decrypted = openssl_decrypt(base64_decode($input), 'AES-256-CBC', $this->key, OPENSSL_RAW_DATA, $this->hexToStr($this->hex_iv));
return $decrypted;
}
/*
For PKCS7 padding
*/
private function addpadding($string, $blocksize = 16) {
$len = strlen($string);
$pad = $blocksize - ($len % $blocksize);
$string .= str_repeat(chr($pad), $pad);
return $string;
}
private function strippadding($string) {
$slast = ord(substr($string, -1));
$slastc = chr($slast);
$pcheck = substr($string, -$slast);
if (preg_match("/$slastc{" . $slast . "}/", $string)) {
$string = substr($string, 0, strlen($string) - $slast);
return $string;
} else {
return false;
}
}
function hexToStr($hex)
{
$string='';
for ($i=0; $i
$string .= chr(hexdec($hex[$i].$hex[$i+1]));}
return $string;
}
}
-
mcrypt_get_block_size():模块初始化失败 - 函数出错
2017-02-21 21:35:32<p>I am trying to ...<p>The error is "mcrypt_get_block_size(): Module initialization failed on line on line 41" which is $block = mcrypt_get_block_size('ISO-8859-1', 'ecb'); <p>Any ideas? </div> -
Fatal error: Call to undefined function mcrypt_get_block_size()
2018-07-10 15:20:54先安装:sudo apt-get install php5-mcrypt安装完成之后需要在cgi里面添加。比如php-fpm里需要在/etc/php5/fpm/conf.d目录下面创建一个软连接:20-mcrypt.ini,他这里面已经有一些软连接了(比如:.20-json.ini -&...首先问题原因是缺少的扩展。
先安装:sudo apt-get install php5-mcrypt
安装完成之后需要在cgi里面添加。
比如php-fpm里需要在
/etc/php5/fpm/conf.d
目录下面创建一个软连接:20-mcrypt.ini,
他这里面已经有一些软连接了(
比如:.
20-json.ini -> ../../mods-available/json.ini
20-mysqli.ini -> ../../mods-available/mysqli.ini
20-readline.ini -> ../../mods-available/readline.ini
),我们只需要照着样式建立一个就行了
指向你安装的那个文件所在目录:
ln -s ../../mods-available/mcrypt.ini 20-mcrypt.ini 这里根据你实际目录来操作。
建立完成以后,需要重新启动php-fpm 或者 spawn-cgi.
原文链接:https://blog.csdn.net/zhanqixuan22/article/details/51077001
-
php7.2 安装mcrypt扩展 Call to undefined function mcrypt_get_block_size
2018-06-08 12:14:43由于mcrypt扩展在php7.2 弃用,所以需要继续使用这个扩展的话需要自行编译mcrypt扩展。 本机环境: ubuntu18.04 php7.2 如果ubuntu版本在16.04 或者14.04 版本,优先尝试使用添加pp:ondreg 安装php,以及php... -
PHP加密3DES报错 Call to undefined function: mcrypt_module_open() 如何解决
2020-10-22 13:09:54主要介绍了PHP加密3DES报错 Call to undefined function: mcrypt_module_open() 如何解决的相关资料,需要的朋友可以参考下 -
Docker - 调用未定义的函数mcrypt_get_block_size()
2017-03-17 08:58:15<p>In docker I get <em>Call to undefined function mcrypt_get_block_size(), in the container I installed php5-mcrypt and in the php.ini I writted extension=mcrypt.so but don't working it.</p> ... -
PHP:mcrypt_get_iv_size()的用法_Mcrypt函数
2021-04-15 14:34:17mcrypt_get_iv_size(PHP 4 >= 4.0.2, PHP 5)mcrypt_get_iv_size — 返回指定算法/模式组合的初始向量大小说明int mcrypt_get_iv_size( string $cipher, string ...mcrypt_enc_get_iv_size() 更加有用,因为它使用... -
[PHP]解决PHP Fatal error: Call to undefined function mcrypt_get_iv_size()
2021-03-26 12:40:18当使用mcrypt_get_iv_size这个函数的时候 需要安装php-mcrypt扩展 centos下 yum install php-mcrypt -
当不需要IV时,PHP的mcrypt_get_iv_size是否实际返回零?
2021-04-15 14:34:19在PHP documentation for mcrypt_get_iv_size中,声明当算法/块模式组合不使用IV时,返回值将为零:Returns the size of the Initialization Vector (IV) in bytes. On error the function returns FALSE. If the IV ... -
函数mcrypt_get_iv_size()已弃用 - Heroku
2017-02-17 02:12:21<p>Function mcrypt_get_iv_size() is deprecated <p><strong>config/app.php</strong></p> <p><code>'cipher' => 'AES-256-CBC',</code></p> <p><a href=... -
PHP的openssl_encrypt替换mcrypt_encrypt方法汇总
2021-04-23 06:09:27由于mcrypt_encrypt的函数在PHP7中已经被废弃,在之前的项目中有一个加密函数需要转换,代码如下:$encryptString = 'lensuntop encrypt';$key = pack('H*', "bfdecc6724cc96548fb653fa965588c");$iv = pack('H*', ... -
Uncaught Error: Call to undefined function mcrypt_get_iv_size() 解决办法
2019-06-05 17:06:27函数 mcrypt_get_iv_size 在只在(PHP 4 >= 4.0.2, PHP 5, PHP 7 < 7.2.0, PECL mcrypt >= 1.0.0) 这几个版本中有效。 旧版本的PHP中大部分都是用这个来生成加密。新的PHP7.3的版本中可以用openssl_encrypt... -
php7 替换 mcrypt_decrypt,mcrypt_encrypt
2020-06-22 11:21:48php7 替换 mcrypt_decrypt,mcrypt_decrypt,mcrypt_encrypt -
转载>php7以上 不支持mcrypt_module_open方法问题【微信开放平台】
2020-12-13 10:48:05// 网络字节序 $size = mcrypt_get_block_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC); $module = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', MCRYPT_MODE_CBC, ''); $iv = substr($this->key, 0, 16); //使用... -
升级 PHP7.1 后 openssl 解密 mcrypt AES 数据不兼容问题的处理方法
2020-12-17 23:13:43这是一个创建于 374 天前的...$en_data = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, "0123456789123456", MCRYPT_MODE_CBC, $iv)); var_dump("mcrypt_encrypt:"); var_dump(bin2hex(base64_decode($en_ -
PHP 将 mcrypt_encrypt 迁移至 openssl_encrypt 的方法
2021-04-16 01:25:39其实在 2015 就已经开始建议大家使用 openssl_encrypt/openssl_decrypt 来代替mcrypt_encrypt/mcrypt_decrypt,缓冲了 N 久,这一天终于在 7.2.0 版本上到来了。为什么要提及迁移,比如 A & B 两套系统使... -
PHP7.2中AES加密解密方法mcrypt_module_open()替换方案
2020-05-23 12:11:26php的mcrypt 扩展已经过时了大约10年,并且用起来很复杂。因此它被废弃并且被 OpenSSL 所取代。 从PHP 7.2起它将被从核心代码中移除并且移到PECL中。PHP手册在7.1迁移页面给出了替代方案,就是用OpenSSL取代MCrypt. ... -
mcrypt_encrypt
2021-04-08 10:20:31but on the decryption part came back with the error: "The IV parameter must be as long as the blocksize". After a while i figured out that the generated IV string will... -
mcrypt弃用,使用openssl_encrypt,接收微信推送的数据进行解密、加密踩坑
2021-06-18 10:13:07// 网络字节序 $size = mcrypt_get_block_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC); $module = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', MCRYPT_MODE_CBC, ''); $iv = substr($this->key, 0, 16); //使用... -
PHP7.1中使用openssl替换mcrypt的实例详解
2021-03-23 21:14:42在迁移手册中已经指出了用openssl代替mcrypt,但未给出具体示例。网上有很多示例,可以替换大部分场景,但对于其中细节却并未说明。同样,简单地使用网上示例在某种代码场景下有可能导致代码替换前后的兼容问题,...