Re: libmcrypt usage
| From: | Gary | Date: | Fri, 17 Sep 2010 13:15:43 +0000 |
| Subject: | Re: libmcrypt usage | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-308144@lists.php.net to get a copy of this message | ||
Nathan Rixham wrote:
> Gary wrote:
>> Nathan Rixham wrote:
>>> Gary wrote:
>>>> Can anyone tell me what the equivalent to the following command line
>>>> usage of openssl is, in php using the mcrypt_* functions, please:
>>>> ,----
>>>> | openssl enc -e -aes-256-cbc -k <some key> ...
>>>> `----
>>> use MCRYPT_RIJNDAEL_128
>>
>> Err.. why, if you don't mind me asking?
>>
>
> because MCRYPT_RIJNDAEL_128 is the implementation of AES
Huh? Why call it 128 if you actually want to use AES 256?
Anyway, thanks to your help and that of Dave Thompson on the openssl
mailing list it's sorted out.
For the record I needed to
1. Make sure the salt is included in the data sent to the receiver
(mcrypt does *not* do this for you)
2. Pad the output per PKCS#5
3. Encrypt using the correct mcrypt function (mcrypt_generic, apparently)
http://juan.axisym3.net/2010/03/16/write-openssl-files-in-php/
was very
helpful in terms of choosing which specific mcrypt encryption function
to call (and in fact describes exactly what I was trying to do).
--
Gary Please do NOT send me 'courtesy' replies off-list.
PHP 5.2.12 (cli) (built: Jan 14 2010 14:54:11)
1.7.7(0.230/5/3) 2010-08-31 09:58 Cygwin