OpenSSLRSA.h
来源:互联网 发布:网络协议基础知识 编辑:程序博客网 时间:2024/06/08 16:55
#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
#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
0 0
- OpenSSLRSA.h
- OpenSSLRSA.cpp
- h
- h
- h
- ,h
- h
- h
- H
- h
- h
- h
- H
- h
- H
- H
- h
- H
- HTML5+、mui开发移动app
- php常用加密技术(包括密码加密及URL加密)
- log4j.properties配置详解
- Git 常用操作
- NYOJ-开灯问题
- OpenSSLRSA.h
- 推荐系统重要会议和期刊
- poj 1111bfs
- jQuery学习笔记之事件
- php需要做的安全防护
- HTML网页开发学习笔记(燕十八)-41 字符实体
- 【开源框架】Android之史上最全最简单最有用的第三方开源库收集整理,有助于快速开发,欢迎各位网友补充完善
- 不同数据库中查询前几条记录的用法(SQL Server/MYSQL /Oracle/Postgresql)
- 如何用天纵手机APP快速开发框架开发手机APP