Base64.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. // CBase64.h: interface for the CBase64 class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. #if !defined(AFX_CBase64_H__B2E45717_0625_11D2_A80A_00C04FB6794C__INCLUDED_)
  5. #define AFX_CBase64_H__B2E45717_0625_11D2_A80A_00C04FB6794C__INCLUDED_
  6. #include <windows.h>
  7. #define lCONTEXT char
  8. #define PlCONTEXT lCONTEXT*
  9. class CBase64
  10. {
  11. // Internal bucket class.
  12. class TempBucket
  13. {
  14. public:
  15. BYTE nData[4];
  16. BYTE nSize;
  17. void Clear() { ::ZeroMemory(nData, 4); nSize = 0; };
  18. };
  19. PBYTE m_pDBuffer;
  20. PBYTE m_pEBuffer;
  21. DWORD m_nDBufLen;
  22. DWORD m_nEBufLen;
  23. DWORD m_nDDataLen;
  24. DWORD m_nEDataLen;
  25. public:
  26. CBase64();
  27. virtual ~CBase64();
  28. public:
  29. virtual void Encode(const PBYTE, DWORD);
  30. virtual void Decode(const PBYTE, DWORD);
  31. virtual void Encode(LPCSTR sMessage);
  32. virtual void Decode(LPCSTR sMessage);
  33. virtual LPCSTR DecodedMessage() const;
  34. virtual LPCSTR EncodedMessage() const;
  35. virtual void AllocEncode(DWORD);
  36. virtual void AllocDecode(DWORD);
  37. virtual void SetEncodeBuffer(const PBYTE pBuffer, DWORD nBufLen);
  38. virtual void SetDecodeBuffer(const PBYTE pBuffer, DWORD nBufLen);
  39. protected:
  40. virtual void _EncodeToBuffer(const TempBucket &Decode, PBYTE pBuffer);
  41. virtual ULONG _DecodeToBuffer(const TempBucket &Decode, PBYTE pBuffer);
  42. virtual void _EncodeRaw(TempBucket &, const TempBucket &);
  43. virtual void _DecodeRaw(TempBucket &, const TempBucket &);
  44. virtual BOOL _IsBadMimeChar(BYTE);
  45. static char m_DecodeTable[256];
  46. static BOOL m_Init;
  47. void _Init();
  48. };
  49. #endif // !defined(AFX_CBase64_H__B2E45717_0625_11D2_A80A_00C04FB6794C__INCLUDED_)