note 69469 added to ref.mcrypt
| From: | pixelchutesATgmailDOTcom at osu1 dot php dot net | Date: | Thu, 07 Sep 2006 01:49:46 +0000 |
| Subject: | note 69469 added to ref.mcrypt | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-116794@lists.php.net to get a copy of this message | ||
For those looking for a mysql_aes_decrypt, I created this method, referencing rolf's
aes_encrypt below. Since the aes_encrypt right-pads N * blocksize with any chr( 0 ) to chr( 16 )
(random based on the input string length) we first decrypt the text, then RTrim chr(0 .. 16)
depending on its trailing ord() value.
mysql AES_DECRYPT() compatibly function for PHP :
<?
function mysql_aes_decrypt( $val, $ky )
{
$mode = MCRYPT_MODE_ECB;
$enc = MCRYPT_RIJNDAEL_128;
$dec = @mcrypt_decrypt($enc, $ky, $val, $mode, @mcrypt_create_iv(
@mcrypt_get_iv_size($enc, $mode), MCRYPT_DEV_URANDOM ) );
return rtrim( $dec, ( ( ord(substr( $dec, strlen( $dec )-1, 1 )) >= 0 and ord(substr(
$dec, strlen( $dec )-1, 1 ) ) <= 16 ) ? chr(ord(substr( $dec, strlen( $dec )-1, 1 ))): null) );
}
?>
Please note that if the strlen($ky)>16 then this function will not be compatible.
----
Server IP: 66.163.161.117
Probable Submitter: 71.219.21.71
----
Manual Page -- http://www.php.net/manual/en/ref.mcrypt.php
Edit -- https://master.php.net/note/edit/69469
Del: integrated -- https://master.php.net/note/delete/69469/integrated
Del: useless -- https://master.php.net/note/delete/69469/useless
Del: bad code -- https://master.php.net/note/delete/69469/bad+code
Del: spam -- https://master.php.net/note/delete/69469/spam
Del: non-english -- https://master.php.net/note/delete/69469/non-english
Del: in docs -- https://master.php.net/note/delete/69469/in+docs
Del: other reasons-- https://master.php.net/note/delete/69469
Reject -- https://master.php.net/note/reject/69469
Search -- https://master.php.net/manage/user-notes.php