开发者

Php mcrypt isn't working properly

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜