hopefully someone who knows what they're doing can reply to you, but in the
meantime this should get you going - it works for me:
$td = mcrypt_module_open(MCRYPT_TripleDES, "", MCRYPT_MODE_ECB,
"/usr/lib/mcrypt-modes");
$iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($td), MCRYPT_RAND);
mcrypt_generic_init($td, "your key string here", $iv);
then just use mdecrypt_generic($td, $data) and mcrypt_generic($td, $data)
where $data is your string to encrypt
----- Original Message -----
From: "Dr. Evil" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, August 20, 2001 11:03 AM
Subject: [PHP] Using mcrypt in PHP
>
> 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]
>
>
--
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]