How to replace mcrypt in php

藏色散人
Release: 2023-03-17 10:32:01
Original
1834 people have browsed it

How to replace mcrypt with php: 1. Open the corresponding php file; 2. Find the original encryption and decryption code; 3. Use the "openssl_encrypt" and "openssl_decrypt" methods to replace it.

How to replace mcrypt in php

The operating environment of this tutorial: Windows 7 system, PHP version 8.1, Dell G3 computer.

php How to replace mcrypt?

Mcrypt encryption and decryption alternative in php7.4

Problem description

The mcrypt_encrypt and mcrypt_decrypt functions have been abandoned since PHP 7.1.0. The original project (php5. 6) The mcrypt_encrypt and mcrypt_decrypt functions used in php7.1 and later environments will prompt that the function cannot be found, and you need to use openssl_encrypt and openssl_decrypt instead.

Solution

********************Encryption*************** ********


        
Copy after login
rrree

************************Decryption************ ************


        
Copy after login
/** * 原解密方法 * @param $str * @param string $key * @return string */ function des_decrypt($str, $key='uK9pFn56') { $str = mcrypt_decrypt(MCRYPT_DES, $key, base64_decode($str), MCRYPT_MODE_ECB); $len = strlen($str); $block = mcrypt_get_block_size('des', 'ecb'); $pad = ord($str[$len - 1]); return substr($str, 0, $len - $pad); } var_dump(des_decrypt("BKG4i231OB0=")); //解密结果:123123
Copy after login

Recommended study: "PHP Video Tutorial"

The above is the detailed content of How to replace mcrypt in php. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!