openssl_aes_cbc.h
1.09 KB
#ifndef ETRADECLIENT_UTILITY_OPENSSL_AES_CBC_H_INCLUDED
#define ETRADECLIENT_UTILITY_OPENSSL_AES_CBC_H_INCLUDED
#include <string>
/*Notice: the APIs of "openssl_aes" may throw exceptions when error happens, these exception messages contain
Chinese characters which are encoding in GBK encoding, so the caller has to call "gbk_2_wstr" to convert the
exception message to std::wstring in Unicode encoding.*/
namespace AES_CBC
{
//iKeyIndex:0为默认加密配置文件秘钥,1为dcck秘钥,2为dack秘钥,3为deak秘钥,4为damk秘钥
std::string Encrypt(const std::string& plaintext, int iKeyIndex = 0);
std::string Decrypt(const std::string& ciphertext, int iKeyIndex = 0);
void EncryptToFile(const std::string& plaintext, const std::string& ciphertext_file_name);
std::string DecryptFromFile(const std::string& ciphertext_file_name);
void EncryptFileToFile(const std::string& plaintext_file_name, const std::string& ciphertext_file_name);
void DecryptFileToFile(const std::string& ciphertext_file_name, const std::string& plaintext_file_name);
} // AES_CBC
#endif // ETRADECLIENT_UTILITY_OPENSSL_AES_CBC_H_INCLUDED