PHP 4.0 Bug #3104: Extra character padding in encrypt/decrypt
| From: | gmerrall at email dot com | Date: | Wed, 05 Jan 2000 02:32:16 +0000 |
| Subject: | PHP 4.0 Bug #3104: Extra character padding in encrypt/decrypt | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-14272@lists.php.net to get a copy of this message | ||
From: gmerrall@email.com
Operating system: Linux
PHP version: 4.0 Latest CVS (05/01/2000)
PHP Bug Type: mcrypt related
Bug description: Extra character padding in encrypt/decrypt
Using libmcrypt-2.2.4, PHP 4 (Latest CVS) as Apache 1.3.9 module.
Extra chars are being added either at the encryption or decryption stage using mcrypt_ecb().
This script is an adaption of the script in the PHP manual.
<?php
$key = "this_is_my_key";
$input = "123456789";
printf ("Input Text: %s Count:%s\n", $input, strlen($input));
$encrypted_data = mcrypt_ecb(MCRYPT_TripleDES, $key, $input, MCRYPT_ENCRYPT);
$decrypted_data = mcrypt_ecb(MCRYPT_TripleDES, $key, $encrypted_data, MCRYPT_DECRYPT);
printf ("Decrypt Text: %s Count:%s", $decrypted_data, strlen($decrypted_data));
?>
Output:
Input Text: 123456789 Count:9
Decrypt Text: 123456789 Count:16