#pragma once
#include <string>
#include "define.h"

using namespace std;

namespace base {
	class DLL_EXPORT CEncrypt
	{
	public:
		CEncrypt();
		~CEncrypt();

	public:
		/////////////////////////////////////
		//base64
		static string EncodeBase64(unsigned char* sData, int nDataByte);
		static string DecodeBase64(const char* sData, int nDataByte);

		/////////////////////////////////////
		//rsa
		//sKey:公钥 
		//sValue:待加密的字符
		//return 加密后并且经过base64编码的字符
		static string EncryptRsa(string sKey, string sValue);

		//sKey:私钥
		//sValue:待解密的字符
		//return 先base64解码后解密的字符
		static string DecryptRsa(string sKey, string sValue);

		//sKey:公钥
		//sValue:待解密的字符
		//return 先base64解码后解密的字符
		static string  PubkeyDecryptRsa(string sKey, string sValue);

		/////////////////////////////////////
		//urlencode、urldecode
		static string EncodeUrl(string str);
		static string DecodeUrl(string str);

		static unsigned char ToHex(unsigned char x);
		static unsigned char FromHex(unsigned char x);

		/////////////////////////////////////
		//sha1
		static string EncryptSha1(string str, string sKey);

		//md5
		static string Md5String(string str);
		//字节转16进制字符串
		static string BytesToHexString(unsigned char * pbBytes, unsigned nSize);
	};

};//namespace