添加项目文件。

This commit is contained in:
2024-09-16 17:08:48 +08:00
parent e1bbbf3031
commit 19206ab763
212 changed files with 72298 additions and 0 deletions

54
Include/BASE64.h Normal file
View File

@@ -0,0 +1,54 @@
#ifndef __DAKUANG_BASE64_H__
#define __DAKUANG_BASE64_H__
#include <string>
namespace LenheartBase
{
class CBASE64
{
public:
// 生成RSA密钥结构
static void* __genKey(int nBits);
// 生成密钥对输出为PEM字符串
static bool genKeyStrings(std::string& strPrivateKeyPEMString, std::string& strPublicKeyPEMString);
// 执行BASE64编码操作
static std::string encode(const std::string& str);
// 执行BASE64解码操作
static std::string decode(const std::string& str);
// 执行RSA私匙解密操作
static std::string RsaPriDecrypt(const std::string& cipher_text, const std::string& pri_key);
// 执行RSA私匙加密操作
static std::string RsaPriEncrypt(const std::string& clear_text, const std::string& pri_key);
// 使用PEM私钥字符串加密
static bool encryptByPrivatePEMString(const std::string& strIn, std::string& strOut, const std::string& strKeyPEMString);
// 使用PEM公钥字符串加密
static bool encryptByPublicPEMString(const std::string& strIn, std::string& strOut, const std::string& strKeyPEMString);
// 使用PEM公钥字符串解密
static bool decryptByPublicPEMString(const std::string& strIn, std::string& strOut, const std::string& strKeyPEMString);
// 使用RSA执行加密或解密
static bool __encryptOrDecrypt(const std::string& strIn, std::string& strOut, const void* pRSA, const void* pFunc, bool bEncrypt);
private:
// 分组编码
static int __encode(unsigned char* pDest, const unsigned char* pSrc, size_t nSrcLen);
// 分组解码
static int __decode(unsigned char* pDest, const unsigned char* pSrc, size_t nSrcLen);
private:
// 编解码转换表
static unsigned char s_encTable[];
static unsigned char s_decTable[];
};
}
#endif