From: asoft at asoft dot no-ip dot org
Operating system: Windows XP
PHP version: 5.0.1
PHP Bug Type: mcrypt related
Bug description: Functions mcrypt don't work OK?
Description:
------------
$a="hola";
$b=cry($a,'sdglmsdd');
$c=dcry($b,'sdglmsdd')
result: $c!=$a
Correct result: $c==$a
Code until now working in version 4 of php
The function cry work how before. Seem work OK.
The function dcry FAIL. Don't work how before.
Reproduce code:
---------------
function cry($input,$key)
{$input = str_replace("\n","",$input);
$input = str_replace("\t","",$input);
$input = str_replace("\r","",$input);
$key = substr(md5($key),0,24);
$td = mcrypt_module_open ('tripledes', '', 'ecb', '');
$iv = mcrypt_create_iv (mcrypt_enc_get_iv_size ($td), MCRYPT_RAND);
mcrypt_generic_init ($td, $key, $iv);
$encrypted_data = mcrypt_generic ($td, $input);
mcrypt_module_close ($td);
return trim(chop(base64_encode($encrypted_data)));}
function dcry($input,$key)
{$input = str_replace("\n","",$input);
$input = str_replace("\t","",$input);
$input = str_replace("\r","",$input);
$input = trim(chop(base64_decode($input)));
$td = mcrypt_module_open ('tripledes', '', 'ecb', '');
$key = substr(md5($key),0,24);
$iv = mcrypt_create_iv (mcrypt_enc_get_iv_size ($td), MCRYPT_RAND);
mcrypt_generic_init ($td, $key, $iv);
$decrypted_data = mdecrypt_generic ($td, $input);
mcrypt_module_close ($td);
return trim(chop($decrypted_data));}
--
Edit bug report at http://bugs.php.net/?id=29755&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=29755&r=trysnapshot4
Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=29755&r=trysnapshot5
Fixed in CVS: http://bugs.php.net/fix.php?id=29755&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=29755&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=29755&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=29755&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=29755&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=29755&r=support
Expected behavior: http://bugs.php.net/fix.php?id=29755&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=29755&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=29755&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=29755&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=29755&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=29755&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=29755&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=29755&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=29755&r=float