What to use instead of mcrypt_encrypt in php7.1
PHPz
PHPz 2017-06-05 11:08:35
0
1
968

Now there is such a line of code in the program

    
    $encrypted = mcrypt_encrypt(
        MCRYPT_RIJNDAEL_128, 
        "1234567890123456", 
        "123456", 
        MCRYPT_MODE_CBC,
        "1234567890123456"
    );
    
    echo base64_encode($encrypted);
    
    // 得到的结果为 QEwd/DWmy/4yGncCqBofQQ==
    

But in php7.1.*, the mcrypt_encrypt function is no longer allowed to be used, so I would like to ask you what method should I use to get the same result. Searching on the Internet, some people said to use openssl_encrypt Function replacement, but I still can’t get the correct result after testing it;


    echo openssl_encrypt(
        "123456", 
        "AES-128-CBC", 
        "1234567890123456", 
        null, 
        "1234567890123456"
    );
    
    // 得到的结果为 1jdzWuniG6UMtoa3T6uNLA==

Have you ever encountered such a problem? How did you solve it in the end?

PHPz
PHPz

学习是最好的投资!

reply all(1)
Ty80

Did you forget base64_encode in the following result

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template