note 105985 modified in function.mcrypt-decrypt by danbrown
| From: | danbrown@php.net | Date: | Fri, 30 Sep 2011 21:37:22 +0000 |
| Subject: | note 105985 modified in function.mcrypt-decrypt by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-183561@lists.php.net to get a copy of this message | ||
Caution, MCRYPT_RIJNDAEL_256 is not equivalent to AES_256.
The way to make RIJNDAEL be decrypted from AES with openssl is to use MCRYPT_RIJNDAEL_128 and padd
the string to encrypt before encrypting with the follwing function:
<?php
function pkcs5_pad ($text, $blocksize) {
$pad = $blocksize - (strlen($text) % $blocksize);
return $text . str_repeat(chr($pad), $pad);
}
?>
On the decryption, the choosing of AES_256 or AES_128, etc. is based on the keysize used in the
crypting. In my case it was a 128bit key so I used AES_128.
--was--
Caution, MCRYPT_RIJNDAEL_256 is not equivalent to AES_256.
The way to make RIJNDAEL be decrypted from AES with openssl is to use MCRYPT_RIJNDAEL_128 and padd
the string to encrypt before encrypting with the follwing function:
function pkcs5_pad ($text, $blocksize) {
$pad = $blocksize - (strlen($text) % $blocksize);
return $text . str_repeat(chr($pad), $pad);
}
On the decryption, the choosing of AES_256 or AES_128, etc. is based on the keysize used in the
crypting. In my case it was a 128bit key so I used AES_128.
http://php.net/manual/en/function.mcrypt-decrypt.php