OpenSSLRSA.h

#ifndef QL_HEADER_OPENSSL_RSA_H
#define QL_HEADER_OPENSSL_RSA_H


#include <string>
using namespace std;


#include <openssl/rsa.h>


class COpenSSLRSA
{
public:
COpenSSLRSA(void);
~COpenSSLRSA(void);


public:
//RSA公钥加密
std::string EncodeRSAPubKeyData(bool bIsBase64 = true);


//RSA公钥解密
std::string DecodeRSAPubKeyData(bool bIsBase64 = true);


//RSA私钥加密
std::string EncodeRSAPriKeyData(bool bIsBase64 = true);


//RSA私钥解密
std::string DecodeRSAPriKeyData(bool bIsBase64 = true);


// 创建秘钥对文件和秘钥对象
void BuildKey();


// 读取公钥-文件
bool ReadPubRSAByFile();


// 读取私钥-文件
bool ReadPriRSAByFile();


// 读取公钥-内存
bool ReadPubRSAByMem(bool bNeedFormat = true);


// 读取私钥-内存
bool ReadPriRSAByMem(bool bNeedFormat = true);


private:
// 取得秘钥文件内容
void GetKeyFileContent(string filename, string& sKeyText);


// 取得错误信息
void PrintErrMsg(int nRet, char* sFuncName);


public:
// 错误消息
char m_sErrMsg[1024];


// 私钥密码
char m_sPriKeyPwd[256];


// 原文、密文
string m_sText;
string m_sCryptText;


// 公钥、私钥(文本)
string m_sPubKey;
string m_sPriKey;


// 公钥、私钥(文件名)
string m_sPubKeyFile;
string m_sPriKeyFile;


private:
// 公钥、私钥(RSA对象)
RSA* m_pRSAPub; 
RSA* m_pRSAPri;



};


#endif
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值