note 14109 deleted from ref.mcrypt by derick
| From: | derick@php.net | Date: | Fri, 25 Apr 2003 19:09:35 +0000 |
| Subject: | note 14109 deleted from ref.mcrypt by derick | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-47104@lists.php.net to get a copy of this message | ||
Mcrypt support in PHP has gone through cycles and it seems to have finally leveled off.
First, get libmcrypt-2.4.15 (well, that was the lastest as of today) and compile it. Pay no
attention to the mcrypt examples in this manual as most of them will simply cause your web server to
segfault. Here are some functions that I hope will help others with mcrypt.
$sCryptoKey = "whatever";
function
my_encrypt($sString) {
GLOBAL $sCryptoKey;
$iIV = mcrypt_create_iv (mcrypt_get_iv_size (MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND);
$sEncrypted = mcrypt_encrypt (MCRYPT_RIJNDAEL_256, $sCryptoKey, $sString, MCRYPT_MODE_ECB, $iIV);
return($sEncrypted);
} // End function my_encrypt
function
my_decrypt($sString) {
GLOBAL $sCryptoKey;
$iIV = mcrypt_create_iv (mcrypt_get_iv_size (MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND);
$sDecrypted = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $sCryptoKey, $sString, MCRYPT_MODE_ECB, $iIV);
return(trim($sDecrypted));
} // End function my_decrypt