ID:               26283
 User updated by:  stjeffy at hotmail dot com
 Reported By:      stjeffy at hotmail dot com
 Status:           Bogus
 Bug Type:         mcrypt related
 Operating System: windows 2000,linux
 PHP Version:      4.3.2
 New Comment:

Thank you for your reply.
I had try to convert the hex string to the binary string, however The
actual result was not the expected result.
The expected result is calculated by C Language.


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

[2003-11-17 14:00:09] [EMAIL PROTECTED]

The key is expected to be in binary, not hex. Try using 
pack() to convert the string from hex to bin, i.e. 
 
$strKey = pack('H48', "3FD3..."); 
 
J 

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

[2003-11-17 03:14:11] stjeffy at hotmail dot com

Description:
------------
I work with mcrypt to encrypt the string by Triple DES. But I meet with
the key length problem. 
I use a 24BYTE key, the key
is(HEX)3FD3A3DABD10B0FF6EAFB5A0103D386EAF6E3F8CAED6CD93 

After executing a instance, 
the system reports the following error: 
mcrypt_generic_init(): Key size too large; supplied length: 48, max: 24
in 
and cut off the half of the original key to calculate the 3des result.

And I find there exists the same problem in php.net' online help-- the
2nd example provided in http://www.php.net/manual/en/ref.mcrypt.php.

Reproduce code:
---------------
$strSource = "http://www.php.net/test.php";;
$strKey = "3FD3A3DABD10B0FF6EAFB5A0103D386EAF6E3F8CAED6CD93"; 

$td = mcrypt_module_open (MCRYPT_3DES, '', 'ecb', ''); 
$iv = mcrypt_create_iv (mcrypt_enc_get_iv_size ($td), MCRYPT_RAND); 
mcrypt_generic_init ($td, $strKey, $iv); 
$strCode = mcrypt_generic ($td, $strSource); 
mcrypt_generic_end ($td); 
echo base64_encode($strCode);

Expected result:
----------------
w6e8c9Tp0/PejfYYvgJJu3cHUXYg29CQAthGmi480Ng=

Actual result:
--------------
LMke4PuG37H9vP5gvRoVwQkX0hZrtfE9NB/az+lSLcc=


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


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

Reply via email to