Why does something encrypted in PHP not match the same string encrypted in Ruby?

若如初见. 提交于 2019-12-05 06:10:12

Turns out, this is quite easy: The padding is the culprit.

AES is a block cipher, so it works on fixed-size blocks. This means, that the last block will allways be padded, and , you know, the good thing about standards is, that there are so many to chose from. PHP uses zero padding, you will have to look into AESCrypt to find out what Ruby uses.

The same problem exists with the various JS AES libraries and PHP. We ended up in allways doing our own padding, as this has driven me into blood-red fury quite some times.

Ofcourse this explains, why the first part (carrying the info) is identical, while the second part (carrying the padding) is different.

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