MCrypt Entry - Please help, I messed up!!
| From: | Mike Reid | Date: | Wed, 06 Sep 2006 23:41:03 +0000 |
| Subject: | MCrypt Entry - Please help, I messed up!! | ||
| Groups: | php.mirrors | ||
| Request: | Send a blank email to php-mirrors+get-32365@lists.php.net to get a copy of this message | ||
Dear PHP.net--
I posted the following entry, but there are two problems:
1. I forgot to enter my contact info mikereid13 AT gmail DOT com
2. I accidentally submitted using a test key in the params
http://us3.php.net/manual/en/ref.mcrypt.php#69434
How can I edit/update to read as the following:
-------------------------
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 its initial
length :)
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. -------------------------- Thanks, please let me know!! Mike