AES Encryption / Decryption with Java 1.5 and ActionScript as3crypto

怎甘沉沦 提交于 2019-12-11 18:08:09

问题


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


回答1:


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?



来源:https://stackoverflow.com/questions/5578701/aes-encryption-decryption-with-java-1-5-and-actionscript-as3crypto

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!