views:

108

answers:

3

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.

A: 

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

David M
RC4 is all byte oriented. I've never seen an implementation with an endianness issue.
GregS
A: 

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

Artyom
RC4 algorithm does not use the IV as far as I know
cyberwaste
+1  A: 

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?

KTC
+1, it looks like the AS3 encryptor returns the encryption as a hex-encoded string. The AS3 decryptor assumes the string is in that form and first decodes it from hex.
GregS