php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #3104 Extra character padding in encrypt/decrypt
Submitted: 2000-01-05 03:32 UTC Modified: 2000-01-08 06:51 UTC
From: gmerrall at email dot com Assigned:
Status: Closed Package: mcrypt related
PHP Version: 4.0 Latest CVS (05/01/2000) OS: Linux
Private report: No CVE-ID: None
 [2000-01-05 03:32 UTC] gmerrall at email dot com
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     



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-01-08 06:51 UTC] sas at cvs dot php dot net
Input buffers will always be NUL-padded to match the blocksize of the respective algorithm.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed May 01 22:01:31 2024 UTC