as3 java 通用 加解密,AES加密/解密与Java 1.5和ActionScript as3crypto

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.

Same encryption algorithm (duh!)

Same size of the key (128/192/256)

Same key

Same initialization vector (For some modes of operations, doesn't apply for CTS)

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值