开发者

Two RC4 implementations generated different encryption results

开发者 https://www.devze.com 2023-01-03 04:05 出处:网络
Why is encryption algorithm may give different results 开发者_如何学编程in AS3 and PHP? In AS3 I use library from http://labs.boulevart.be/index.php/2007/05/23/encryption-in-as2-and-as3/.

Why is encryption algorithm may give different results 开发者_如何学编程in AS3 and PHP? In AS3 I use library from http://labs.boulevart.be/index.php/2007/05/23/encryption-in-as2-and-as3/. And in PHP I use RC4 Cipher.

Could some tell me what is the problem? Thanks.


How are you comparing the two results? You could be looking at one result display as a hex string, and another in ASCII for example. Have you also tried comparing the result to online (such as from Wikipedia) test vector for some simple strings to see if you are getting expected result?


Assuming the obvious like having the same key and initialisation values, you may want to look at the endianness assumptions of the two implementations.


If initial vector (iv) of the encryption libraries in not same (and it is unlikely to be the same as it should be random) the encryption will not give you same result.

If you want to check - check encryption with one and decryption with other and vise-verse

0

精彩评论

暂无评论...
验证码 换一张
取 消