decrypt a as3crypto encrypted text in PHP

后端 未结 2 863
星月不相逢
星月不相逢 2021-01-16 12:04

i tried to encrypt a text in as3crypto via the demo app.

now i am trying to decrypt the crypted text via php but it seems that the text is not properly decrypted. ha

2条回答
  •  盖世英雄少女心
    2021-01-16 13:06

    the issue probably lies in your key. While you can feed a hex string to as3crypto and it will know what do to with it, mcrypt_decrypt will interpret each character as it's underlying ASCII value (like a = 97) instead of it's hexadecimal value (a = 10). Use the hex2bin method to convert the hex string into a byte string, and your decryption should probably work fine.

    also, an issue may rest with different ideas of a default IV (initialization vector) between as3crypto and php. Since you are using CBC mode, you should be specifying an IV, just as a good security practice. also be aware of the potential pitfalls similar to those with your key, of specifying a hex string in as3 and needing to convert it in php.

提交回复
热议问题