开发者

Php mcrypt isn't working properly

开发者 https://www.devze.com 2023-03-14 13:34 出处:网络
I have this code: $original = \'zner5\'; $new = mcrypt_decrypt( MCRYPT_3DES, \'keyCodeEncryption\', \'C¹`Û‡”fa\', \'ecb\');

I have this code:

$original = 'zner5';
$new = mcrypt_decrypt( MCRYPT_3DES, 'keyCodeEncryption', 'C¹`Û‡”fa', 'ecb');
if( $original == $new)
{
    echo "$original == $new";
}
开发者_开发百科else
{
    echo "$original != $new";
}

It outputs 'zner5 != zner5'. Why?


I seem to remember hitting this issue myself some time ago, and if I recall correctly, mcrypt_decrypt() might give you a binary string with extra zero bytes on the end, so try this:

$new = trim(mcrypt_decrypt(...));


Try to use strcmp instead of == to test equality.

0

精彩评论

暂无评论...
验证码 换一张
取 消