How to decrypt a string with OpenSSL which was previously encrypted with mcrypt?

孤者浪人 提交于 2019-12-01 05:54:13

OpenSSL doesn't have the Rijndael-256 cipher; there's no equivalent - you'll have to decrypt and re-encrypt everything.

But also:

  • You're missing padding and authentication.
  • Don't use ECB mode.
  • "salt" is not a proper encryption key, nor is any regular string. Use random_bytes() to generate your keys, with the proper key length for the chosen algorithm.

All of the above can be summed up like this: don't do it on your own, use a well-vetted library like defuse/php-encryption.

Cryptography is no simple thing and you can't do it properly with just 5 lines of code.

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