Edit report at http://bugs.php.net/bug.php?id=52989&edit=1
ID: 52989
Comment by: uramihsayibok at gmail dot com
Reported by: info at wtovn dot com
Summary: the mcrypt_encrypt and mcrypt_decrypt functions are
not accurate working.
Status: Open
Type: Bug
Package: *Encryption and hash functions
Operating System: WIN32
PHP Version: 5.3SVN-2010-10-05 (snap)
Block user comment: N
New Comment:
Not a bug. It's due to the nature of DES.
The least significant bit of each byte in the key is NOT USED, and the
only difference between the characters '0' and '1' is that least
significant bit. You can see the same behavior swapping 'B' and 'C', 'P'
and 'Q', and 'x' and 'y' (to give some examples). Generically, any
even-numbered ASCII character can be swapped with its n+1 neighbor, and
vice versa.
Separately: ECB mode does not use IVs so $iv is pointless.
Previous Comments:
------------------------------------------------------------------------
[2010-10-05 06:24:39] info at wtovn dot com
Description:
------------
the mcrypt_encrypt and mcrypt_decrypt functions are not accurate
working.
please see script below.
Test script:
---------------
$data = "Cá»ng hòa xã há»i chá»§ nghÄ©a viá»t nam, Äá»c láºp
tự do hạnh phúc";
$iv_size = mcrypt_get_iv_size(MCRYPT_3DES, MCRYPT_MODE_ECB);
$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
$key = "01";
$crypttext = mcrypt_encrypt(MCRYPT_3DES, $key, $data,
MCRYPT_MODE_ECB, $iv);
$key = "10";
$decrypt = mcrypt_decrypt (MCRYPT_3DES, $key , $crypttext ,
MCRYPT_MODE_ECB, $iv) ;
then result are :
$data = $decrypt ????
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=52989&edit=1