PHP : OpenSSL equivilent of mcrypt : MCRYPT_3DES?

2019-08-08 04:30发布

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条回答
小情绪 Triste *
2楼-- · 2019-08-08 05:12

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.

查看更多
登录 后发表回答