note 71415 added to function.mcrypt-encrypt
| From: | davidwhthomas at gmail | Date: | Tue, 28 Nov 2006 01:37:52 +0000 |
| Subject: | note 71415 added to function.mcrypt-encrypt | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-120115@lists.php.net to get a copy of this message | ||
Here's two simple functions to encrypt and decrypt a string:
function encryptData($value){
$key = "top secret key";
$text = $value;
$iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
$crypttext = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $text, MCRYPT_MODE_ECB, $iv);
return $crypttext;
}
function decryptData($value){
$key = "top secret key";
$crypttext = $value;
$iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
$decrypttext = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, $crypttext, MCRYPT_MODE_ECB, $iv);
return trim($decrypttext);
}
----
Server IP: 203.89.181.184
Probable Submitter: 203.171.40.14
----
Manual Page -- http://www.php.net/manual/en/function.mcrypt-encrypt.php
Edit -- https://master.php.net/note/edit/71415
Del: integrated -- https://master.php.net/note/delete/71415/integrated
Del: useless -- https://master.php.net/note/delete/71415/useless
Del: bad code -- https://master.php.net/note/delete/71415/bad+code
Del: spam -- https://master.php.net/note/delete/71415/spam
Del: non-english -- https://master.php.net/note/delete/71415/non-english
Del: in docs -- https://master.php.net/note/delete/71415/in+docs
Del: other reasons-- https://master.php.net/note/delete/71415
Reject -- https://master.php.net/note/reject/71415
Search -- https://master.php.net/manage/user-notes.php