note 13741 rejected and deleted from ref.mcrypt.php by zak

From: Date: Mon, 02 Jul 2001 21:17:26 +0000
Subject: note 13741 rejected and deleted from ref.mcrypt.php by zak
Groups: php.notes 
Request: Send a blank email to php-notes+get-14924@lists.php.net to get a copy of this message
The mcyrpt functions seem to be doing some funny things with double-byte character strings. This may be related to Avinesh's example above, but I tried his code and it didn't work. Anyway, I have tried encrypting a 9-character password using MCRYPT_RC2 in CBC mode, with a random 8-char IV. I concatentate the IV onto the end of the encrypted string and then store the resulting 24-character string in a VARCHAR() column in a PostgreSQL database. When I retrieve the encrypted value and then decrypt it and store it in a var, the length of the var is 16 bytes. Printing the var on the screen shows exactly the same text as I originally started with (which is the desired result of course), except this rogue "string" is 16 bytes, I thought it should be 9. To make matters worse, if I need to concatenate the decrypted password to some other POST vars and use them to talk to a remote server. For example, $string = $decryptedstring . $string When I do that, all of the string content that should be after the decrypted password string ($string above) disappears! It looks like a memory leak is the cause, but then again I'm not too swift with single-byte, double-byte char sets and such. Any ideas??

« previous php.notes (#14924) next »