note 14109 added to ref.mcrypt.php
| From: | mvincent at cablespeed dot nospam dot com | Date: | Tue, 17 Jul 2001 22:01:01 +0000 |
| Subject: | note 14109 added to ref.mcrypt.php | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-15506@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.
PHP Manual Editor : Can you remove all the outdated comments and examples from the manual? It was
seriously confusing to get to the bottom of the problems I had starting to use mcrypt and it's
fairly straight forward now, I just think the PHP manual needs some updating in this area. Note that
it seems Zend's manual pages have been updated as that's where I finally got some working
example code.
Thanks!!!
$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
http://www.php.net/manual/en/ref.mcrypt.php