AES加密/解密与Java 1.5和ActionScript as3crypto [英] AES Encryption / Decryption with Java 1.5 and ActionScript as3crypto

查看:183
本文介绍了AES加密/解密与Java 1.5和ActionScript as3crypto的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的网站上,我正在使用AES 128bit加密/解密字符串。我加密了Java中的一个字符串,我想在我在同一个网页上运行的Flash应用程序中解密它,我将加密的字符串作为JavaScript变量传递给。





在闪存端,我使用Java生成的密钥(Base64)来对字符串进行解密,注意到它没有正确解密。我在Flash中使用的加密库是 as3crypto 。当我使用我的Java生成的密钥(Base64)在 as3crypto项目的演示页面上测试这一点时,我注意到我没有使用所有可能的模式(CBC,CFB等)得到相同的结果。



这个错误的可能原因是什么?我做错了吗?



感谢

解决方案

难以说没有看看你的代码,但是...



几件事情要注意。



AES加密数据语言之间可以互换,几件事情要考虑。


  1. 相同的加密算法(duh!)

  2. 键大小相同(128/192/256)

  3. 相同的键

  4. 相同的操作模式(ECB / CBC / CTS等)

  5. 相同的初始化向量(对于某些操作模式,不适用于CTS)

  6. 相同填充方案

  7. 字符编码

你确定所有这些在Java和ActionScript之间是相同的?


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.

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.

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?

Regards

解决方案

Hard to say without taking a look at your code but...

Few things to notice.

AES encrypted data to be interchangeable between languages there are few things to consider.

  1. Same encryption algorithm (duh!)
  2. Same size of the key (128/192/256)
  3. Same key
  4. Same Mode of operation (ECB/CBC/CTS etc)
  5. Same initialization vector (For some modes of operations, doesn't apply for CTS)
  6. Same Padding scheme
  7. Character Encoding

Are you sure that all of these are the same between both Java and ActionScript?

这篇关于AES加密/解密与Java 1.5和ActionScript as3crypto的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆