mcrypt_cbc when using libmcrypt 2.4.x?
| From: | Lance Lovette | Date: | Wed, 29 Nov 2000 23:37:35 +0000 |
| Subject: | mcrypt_cbc when using libmcrypt 2.4.x? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-27925@lists.php.net to get a copy of this message | ||
Does anyone have a piece of sample script that calls mcrypt_cbc when using
libmcrypt 2.4.x? I am trying to get the following script ported over to
PHP 4 and I can't find the quickest way to get around the warning "attempt
to use an empty IV, which is NOT recommend". I can't find any code that
actually calls mcrypt_get_block_size with 2 arguments.
Thanks!
Lance
----
function hex2bin($hex_data)
{
return pack("H" . strlen($hex_data), $hex_data);
}
$value = "what you want to encrypt goes here";
echo $value;
echo "<BR>";
$value = bin2hex(mcrypt_cbc(MCRYPT_TripleDES, "K", $value,
MCRYPT_ENCRYPT));
echo $value;
echo "<BR>";
$value = mcrypt_cbc(MCRYPT_TripleDES, "K", hex2bin($value),
MCRYPT_DECRYPT);
echo $value;
echo "<BR>";