ID: 29172 User updated by: lars at larswolter dot de Reported By: lars at larswolter dot de -Status: Open +Status: Closed Bug Type: mcrypt related Operating System: Windows PHP Version: 5.0.0 New Comment:
The new libmcrypt.dll fixed the problem Thanks Lars Previous Comments: ------------------------------------------------------------------------ [2004-07-16 12:56:12] taomyn at myway dot com Sorry, forgot to mention, I get "ok" with your code. Another thought, did you make sure to get the latest libmcrypt.dll when you upgraded? Mine is dated from 7 April, 2004 which I got from the link within the PHP site. To make sure of a clean upgrade I started with fresh clean folder and used the new PHP.INI from which I modified by taking values out of the v4 one (so I lost any deprecated stuff). ------------------------------------------------------------------------ [2004-07-16 12:52:19] taomyn at myway dot com Have had no problems here under Windows Server 2003. My test code that I used when a previous 4.x upgrade "fixed" a feature but broke my code, still works fine: <? function encrypt_pwd($string) { srand((double) microtime() * 1000000); $key = md5("bubbles"); $td = mcrypt_module_open('des', '','cfb', ''); $key = substr($key, 0, mcrypt_enc_get_key_size($td)); $iv_size = mcrypt_enc_get_iv_size($td); $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND); mcrypt_generic_init($td, $key, $iv); $c_t = mcrypt_generic($td, $string); mcrypt_generic_deinit($td); mcrypt_module_close($td); $c_t = $iv . $c_t; return $c_t; } function decrypt_pwd($string) { $key = md5("bubbles"); $td = mcrypt_module_open('des', '','cfb', ''); $key = substr($key, 0, mcrypt_enc_get_key_size($td)); $iv_size = mcrypt_enc_get_iv_size($td); $iv = substr($string, 0 ,$iv_size); $string = substr($string, $iv_size); mcrypt_generic_init($td, $key, $iv); $c_t = mdecrypt_generic($td, $string); mcrypt_generic_deinit($td); mcrypt_module_close($td); return $c_t; } $password = "muppet"; print "===".$password."===\n"; $password = encrypt_pwd($password); print "===".$password."===\n"; $password = decrypt_pwd($password); print "===".$password."===\n"; ?> Try this code and see what happens on your system. I found the examples on the site at times a bit misleading (or I was having a bad day), but one of the kind developers here showed me my error and the code above is what I now use, Taomyn ------------------------------------------------------------------------ [2004-07-15 11:44:08] [EMAIL PROTECTED] Works fine for me on Linux, I saw this bug before and then it was a Windows issue too. I don't have a development setup for Windows here so I can't really help to track down this problem. ------------------------------------------------------------------------ [2004-07-15 01:47:06] lars at larswolter dot de Description: ------------ Just changed from php4 to php5. Now mcrypt decryption does not work anymore. The function returns the encrypted data instead of the decrypted. The testcode is the example from the mdecrypt_generic function documentation. using php.ini-recommended and only changed the following display_errors = On display_startup_errors = On extensions_dir = ... loaded extra modules: gd2, mbstring, mcrypt, mysql, exif Reproduce code: --------------- <?php $key = 'this is a very long key...'; $plain_text = 'very important data'; $td = mcrypt_module_open('des', '', 'ecb',''); $key = substr($key, 0, mcrypt_enc_get_key_size($td)); $iv_size = mcrypt_enc_get_iv_size($td); $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND); if (mcrypt_generic_init($td, $key, $iv) != -1) { $c_t = mcrypt_generic($td, $plain_text); mcrypt_generic_deinit($td); mcrypt_generic_init($td, $key, $iv); $p_t = mdecrypt_generic($td, $c_t); mcrypt_generic_deinit($td); mcrypt_module_close($td); } if (strncmp($p_t, $plain_text, strlen($plain_text)) == 0) echo "ok"; else echo "error"; ?> Expected result: ---------------- the result should be: ok Actual result: -------------- the result is: error ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=29172&edit=1