当前位置:网站首页>Upgrade PHP to php7 The impact of X (2), the obsolescence of mcrypt decryption

Upgrade PHP to php7 The impact of X (2), the obsolescence of mcrypt decryption

2022-06-25 04:39:00 zepcjsj0801

For me who lacks theory , Copy and paste the following paragraph directly

Stick the code directly , This class is provided based on wechat official account message encryption and decryption PHP DEMO And to

php Of mcrypt Extensions are out of date about 10 year , And it is very complicated to use . So it was abandoned and OpenSSL replaced . from PHP 7.2 It will be removed from the core code and moved to PECL in .PHP Manual in 7.1 The migration page gives an alternative , Just use OpenSSL replace MCrypt.

  The following content is modified from my own real weapon , The contrast is obvious .

The following is the original code

$decrypted = openssl_decrypt(base64_decode($packet['encrypt']), 'AES-256-CBC', $key, OPENSSL_RAW_DATA, $iv);               /*
        $ciphertext_dec = base64_decode($packet['encrypt']);
        $module = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', MCRYPT_MODE_CBC, '');
        $iv = substr($key, 0, 16);
        mcrypt_generic_init($module, $key, $iv);
        $decrypted = mdecrypt_generic($module, $ciphertext_dec);
        mcrypt_generic_deinit($module);
        mcrypt_module_close($module);         */         

原网站

版权声明
本文为[zepcjsj0801]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202210534149458.html