PHP error mcrypt_encrypt / mcrypt_decrypt, returns a different value

I searched for the answer, but did not find it here. Please excuse me if this question is already asked.

I have simple code encryption and line decryption, the lines look the same, but when comparing them using == they do not seem to be the same, so the hashes are also different.

Here is my code:

$oppa = "rompish";
$opp_enc = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, "key", $oppa, MCRYPT_MODE_ECB);
$opp_dec = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, "key", $opp_enc, MCRYPT_MODE_ECB);

echo $oppa."<br />".$opp_dec."<br />";

if ($oppa == $opp_dec) echo "YAY"; else echo "NOPE";

On the page:

noisy noisy nope

Please tell me what I'm doing wrong.

Thank!

+5
source share
1 answer

AES 16 . mcrypt_encrypt , 16. mcrypt_decrypt , . , oppa_dec 9 . . - GregS

, rtrim. .

+2

All Articles