There seems to be no reliable information in the manual about how to
do this.  I'm trying to use mcrypt 2.4 with php4.06, which should be a
compatible combination.

So far, I have gotten it to work like this:

$cypher = MCRYPT_RIJNDAEL_128;
$encrypted = mcrypt_encrypt($cypher, $key, $plaintext, MCRYPT_MODE_ECB); 
$decrypted = mcrypt_decrypt($cypher, $key, $encrypted, MCRYPT_MODE_ECB);

However, when I do this, I get an error saying:

Warning: attempt to use an empty IV, which is NOT recommend in

So I tried to do the same thing with an IV:

$iv = mcrypt_create_iv(mcrypt_get_iv_size($cypher, MCRYPT_MODE_ECB),
MCRYPT_RANDOM);

and then added this $iv as an argument to encrypt and decrypt.  At
this point, it doesn't work, because the iv is different in the
encrypt and decrypt functions, because it is randonly generated.  Is
it true that I need the same iv to encrypt as to decrypt?  I'm just
not understanding how to use this.  All I want to do is to encrypt
stuff and then decrypt it, using a key, right?  It used to work.

Thanks.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to