问题
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