AES加密/解密与Java 1.5和ActionScript as3crypto [英] AES Encryption / Decryption with Java 1.5 and ActionScript as3crypto
问题描述
在我的网站我使用一个字符串的AES 128位加密/解密。我加密的字符串在Java中,我想解密它在我运行在同一个网页上的Flash应用程序,而我经过加密的字符串作为一个JavaScript变量。
On my website I am using AES 128bit encryption/decryption of a string. I encrypt a string in Java and I want to decrypt it in a flash application that I run on the same webpage, to which I pass the encrypted string as a JavaScript variable.
我生成使用Java 128位密钥。我可以做加密/解密在Java中成功。 Java的输出字节数组(byte []的)为重点,加密和解密的结果。我使用Base64编码/解码顺利拿到字符串等价。
I generate a 128bit key using Java. I can do encryption/decryption in Java successfully. Java outputs byte-array (byte[]) for the key, encrypted and decrypted result. I use Base64 encoding/decoding to successfully get the string equivalent.
在闪一边,我使用Java生成的密钥的(Base64)做字符串的解密和我注意到,这是不正确解密。我在Flash中使用的加密库是 as3crypto 。当我测试这个as3crypto项目的演示页使用我的Java生成的密钥的(Base64)我注意到说我没有得到利用一切可能的模式(CBC,CFB等)。同样的结果。
On the flash side I use the Java generated key (Base64) to do the decryption of the string and I noticed that it is not correctly decrypted. The cryptography library that I use in flash is as3crypto. When I test this on the demo page of the as3crypto project using my Java generated key (Base64) I noticed that I am not getting the same result using all possible modes (CBC, CFB etc.).
什么是可能的原因这个错误?难道我做错了什么?
What is the possible cause for this error? Am I doing something wrong?
问候
推荐答案
很难不采取看看你的code,但...
Hard to say without taking a look at your code but...
几件事情要注意。
AES加密的数据是可以互换的语言也有一些事情要考虑的。
AES encrypted data to be interchangeable between languages there are few things to consider.
- 在相同的加密算法(废话!)
- 键的相同尺寸(128/192/256)
- 在相同的密钥
- 操作同一种模式(ECB / CBC / CTS等)
- 相同的初始化向量(对于操作的一些模式,不适用于CTS)
- 相同填充方案
- <一个href="http://stackoverflow.com/questions/5295110/aes-encryption-in-java-and-decryption-in-c">Character编码
- Same encryption algorithm (duh!)
- Same size of the key (128/192/256)
- Same key
- Same Mode of operation (ECB/CBC/CTS etc)
- Same initialization vector (For some modes of operations, doesn't apply for CTS)
- Same Padding scheme
- Character Encoding
您确定所有这些都是Java和ActionScript中的一样吗?
Are you sure that all of these are the same between both Java and ActionScript?
这篇关于AES加密/解密与Java 1.5和ActionScript as3crypto的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!