ID:               26733
 Updated by:       [EMAIL PROTECTED]
 Reported By:      n0spam_socrate_omega at hotmail dot com
-Status:           Open
+Status:           Bogus
 Bug Type:         Arrays related
 Operating System: Windows XP Home/Pro
 PHP Version:      4.3.4
 New Comment:

This is not a bug. If you use a block cipher like Rijndael then mcrypt
needs to pad your data with zeroes to fill up the whole block to
encrypt. If you are decrypting the encrypted string those trailing
zeroes are still there, and thus the comparison of the last element
fails. 

Before you start asking if we can't trim the string while decrypting;
no this is not possible because we don't know if you are encrypting
binary data (which might end in a zero) or not. You'll have to take
care of this yourself then by using rtrim during comparison.


Previous Comments:
------------------------------------------------------------------------

[2003-12-28 14:01:56] n0spam_socrate_omega at hotmail dot com

Description:
------------
I have a string encrypted with mcrypt and encoded in base64. I unbase64
this string and I decrypt it using mcrypt. I got the exact same string
but when I try to explode it into an array with the explode() function,
I cannot make comparison == with the last element of the newly created
array.

Reproduce code:
---------------
$key = "validkey";
$input = base64_decode($txtEncrypted);  
$decrypted = mcrypt_ecb(MCRYPT_RIJNDAEL_128, $key, $input,
MCRYPT_DECRYPT);

echo $decrypted."<br>";

$array_data = explode('||', $decrypted);

echo "|".$array_data."|<br>";

if ($array_data[8] == 'end') {
   echo "it works!";
}

Expected result:
----------------
data||ddata||daata||dadta||dasta||datad||daata||datsa||end
|end|
it works!

Actual result:
--------------
data||ddata||daata||dadta||dasta||datad||daata||datsa||end
|end|



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=26733&edit=1

Reply via email to