Problems with interoperability: MCrypt AES PHP x Java
| From: | robert mena | Date: | Tue, 09 Aug 2011 16:52:22 +0000 |
| Subject: | Problems with interoperability: MCrypt AES PHP x Java | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-314452@lists.php.net to get a copy of this message | ||
Hi,
I am having problems while trying to decrypt an encrypted string (generated
from a java system) in PHP.
To take external factors out of the way I decided to make them work first in
my local system.
So I've created a sample encrypt/decrypt from PHP (using mcrypt's extension)
and the java code found at
http://java.sun.com/developer/technicalArticles/Security/AES/AES_v1.html.
I've added a System.out.println("KEY: " + asHex(raw));
to get the key used in the java and set the same in PHP. There is no
mention in Java but since I didn't see a initialization vector I assume we
are use ECB mode.
Unfortunately the same string /key produces different encrypted values.