Uncaught Error: Call to undefined function mcrypt_get_iv_size() 解决办法

The only function mcrypt_get_iv_size (PHP 4> = 4.0.2, PHP 5, PHP 7 <7.2.0, PECL mcrypt> = 1.0.0) effective in several versions.

Most older versions of PHP are using this to generate the encryption. The new version can be used in PHP7.3 openssl_encrypt to generate an encrypted text.

$cipher = openssl_encrypt($plain, 'AES-128-ECB', $key, OPENSSL_RAW_DATA);
$cipher = bin2hex($cipher);

 

The old code is as follows:

// aes128加密
$iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_ECB);
$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
$cipher = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $plain, MCRYPT_MODE_ECB, $iv); //ECB模式,IV不起作用

 

One way to determine the version of PHP

PHP_VERSION_ID> 70000

Original link: https: //blog.csdn.net/default7/article/details/90905510

Guess you like

Origin www.cnblogs.com/iitrust/p/12339984.html