PHP : OpenSSL equivilent of mcrypt : MCRYPT_3DES?

夙愿已清 提交于 2019-12-11 05:47:52

问题


We would like to convert our use of mcrypt to openssl.

Here is our encryption function:

mcrypt_ecb(MCRYPT_3DES,$key,$payload,MCRYPT_ENCRYPT)

Here is our decryption function:

mcrypt_ecb(MCRYPT_3DES,$key,$payload,MCRYPT_DECRYPT)

What are the openssl_* equivalents of the above?

Thanks.


回答1:


I think you're looking for the EVP_Encrypt... functions with EVP_des_ede3 as the cipher (although you should really be using CBC mode rather than ECB).

https://www.openssl.org/docs/crypto/EVP_EncryptInit.html#

If it helps, I have a short example for AES written in C++ at https://github.com/shanet/Crypto-Example. Converting it to use triple DES should be trivial.



来源:https://stackoverflow.com/questions/18102056/php-openssl-equivilent-of-mcrypt-mcrypt-3des

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