On Sun, 2004-02-08 at 05:18, [EMAIL PROTECTED] wrote: > Hi all, > I have problem with mcrypt function. > There is always an error that I don't know how to correct this. > This is my code: > > $string = "Text string"; > $key= "My key"; > $encrypted = mcrypt_cfb(MCRYPT_RIJNDAEL-256, $key, $string, MCRYPT_ENCRYPT); > echo"stringa cifrata= $encrypted"; > $key = "My key"; > $string = mcrypt_cfb(MCRYPT_RIJNDAEL-256, $key, $encrypted, MCRYPT_DECRYPT); > echo"stringa decifrata= $string";
If you are using mycrypt 2.4.x you need to do something like this: encrypt: # initialize the encryption module $mc_module = mcrypt_module_open(MCRYPT_RIJNDAEL_256, '', MCRYPT_MODE_ECB, ''); mcrypt_generic_init($mc_module, $encryption_key, $iv); # encrypt the data $encrypted_data = mcrypt_generic($mc_module, $data); # de-initialize the encryption module mcrypt_generic_deinit($mc_module); mcrypt_module_close($mc_module); decrypt: # initialize the encryption module $mc_module = mcrypt_module_open(MCRYPT_RIJNDAEL_256, '', MCRYPT_MODE_ECB, ''); mcrypt_generic_init($mc_module, $encryption_key, $iv); # decrypt the data $decrypted_data = mdecrypt_generic($mc_module, $encrypted_data); # trim any trailing \0, encrypted data is automatically padded to a 32byte boundary with \0 $decrypted_data = rtrim($decrypted_data); # de-initialize the encryption module mcrypt_generic_deinit($mc_module); mcrypt_module_close($mc_module); Check the documentation[1] for more information on encryption keys and initialization vectors. [1] http://www.php.net/mcrypt -- Adam Bregenzer [EMAIL PROTECTED] http://adam.bregenzer.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php