| 
									
										
										
										
											2022-04-21 13:06:03 +08:00
										 |  |  |  | #ifndef __DAKUANG_BASE64_H__
 | 
					
						
							|  |  |  |  | #define __DAKUANG_BASE64_H__
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | #include <string>
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | namespace LenheartBase | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     class CBASE64 | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |     public: | 
					
						
							| 
									
										
										
										
											2023-04-14 14:56:01 +08:00
										 |  |  |  |         // <20><><EFBFBD><EFBFBD>RSA<53><41>Կ<EFBFBD>ṹ
 | 
					
						
							|  |  |  |  |         static void* __genKey(int nBits); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Կ<EFBFBD>ԣ<EFBFBD><D4A3><EFBFBD><EFBFBD><EFBFBD>ΪPEM<45>ַ<EFBFBD><D6B7><EFBFBD>
 | 
					
						
							|  |  |  |  |         static bool genKeyStrings(std::string& strPrivateKeyPEMString, std::string& strPublicKeyPEMString); | 
					
						
							| 
									
										
										
										
											2022-04-21 13:06:03 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |         // ִ<><D6B4>BASE64<36><34><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
 | 
					
						
							|  |  |  |  |         static std::string encode(const std::string& str); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         // ִ<><D6B4>BASE64<36><34><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
 | 
					
						
							|  |  |  |  |         static std::string decode(const std::string& str); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         // ִ<><D6B4>RSA˽<41><EFBFBD><D7BD>ܲ<EFBFBD><DCB2><EFBFBD>
 | 
					
						
							|  |  |  |  |         static std::string RsaPriDecrypt(const std::string& cipher_text, const std::string& pri_key); | 
					
						
							|  |  |  |  |         // ִ<><D6B4>RSA˽<41><EFBFBD><D7BC>ܲ<EFBFBD><DCB2><EFBFBD>
 | 
					
						
							|  |  |  |  |         static std::string RsaPriEncrypt(const std::string& clear_text, const std::string& pri_key); | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-14 14:56:01 +08:00
										 |  |  |  |         // ʹ<><CAB9>PEM˽Կ<CBBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
 | 
					
						
							|  |  |  |  |         static bool encryptByPrivatePEMString(const std::string& strIn, std::string& strOut, const std::string& strKeyPEMString); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         // ʹ<><CAB9>PEM<45><4D>Կ<EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
 | 
					
						
							|  |  |  |  |         static bool encryptByPublicPEMString(const std::string& strIn, std::string& strOut, const std::string& strKeyPEMString); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         // ʹ<><CAB9>PEM<45><4D>Կ<EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
 | 
					
						
							|  |  |  |  |         static bool decryptByPublicPEMString(const std::string& strIn, std::string& strOut, const std::string& strKeyPEMString); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         // ʹ<><CAB9>RSAִ<41>м<EFBFBD><D0BC>ܻ<EFBFBD><DCBB><EFBFBD><EFBFBD><EFBFBD>
 | 
					
						
							|  |  |  |  |         static bool __encryptOrDecrypt(const std::string& strIn, std::string& strOut, const void* pRSA, const void* pFunc, bool bEncrypt); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     private: | 
					
						
							| 
									
										
										
										
											2022-04-21 13:06:03 +08:00
										 |  |  |  |         // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
 | 
					
						
							|  |  |  |  |         static int __encode(unsigned char* pDest, const unsigned char* pSrc, size_t nSrcLen); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
 | 
					
						
							|  |  |  |  |         static int __decode(unsigned char* pDest, const unsigned char* pSrc, size_t nSrcLen); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     private: | 
					
						
							|  |  |  |  |         // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><D7AA><EFBFBD><EFBFBD>
 | 
					
						
							|  |  |  |  |         static unsigned char s_encTable[]; | 
					
						
							|  |  |  |  |         static unsigned char s_decTable[]; | 
					
						
							|  |  |  |  |     }; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | #endif
 |