note 69434 added to ref.mcrypt
| From: | php-general at lists dot php dot net | Date: | Wed, 06 Sep 2006 04:46:06 +0000 |
| Subject: | note 69434 added to ref.mcrypt | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-116741@lists.php.net to get a copy of this message | ||
For those looking a mysql_aes_decrypt, I was able to create this method, referencing rolf's
aes_encrypt below. Since the aes_encrypt right bads n * blocksize with chr( 0 to 16 ), but is random
based on the input string, we first decrypt the text, then rtrim chr(0 .. 16) depending on it's
initial length :)
mysql AES_DECRYPT() compatibly function for PHP :
function mysql_aes_decrypt( $val, $ky = 's0ftd0c2oo6' )
{
$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/69434
Del: integrated -- https://master.php.net/note/delete/69434/integrated
Del: useless -- https://master.php.net/note/delete/69434/useless
Del: bad code -- https://master.php.net/note/delete/69434/bad+code
Del: spam -- https://master.php.net/note/delete/69434/spam
Del: non-english -- https://master.php.net/note/delete/69434/non-english
Del: in docs -- https://master.php.net/note/delete/69434/in+docs
Del: other reasons-- https://master.php.net/note/delete/69434
Reject -- https://master.php.net/note/reject/69434
Search -- https://master.php.net/manage/user-notes.php