Base64.h
上传用户:weimei12
上传日期:2022-08-11
资源大小:185k
文件大小:3k
- #pragma once
- /********************************************************************
- created: 2008:10:29 11:02
- author: 李欣
- filename: c:MyProjectSimpleMailSimpleMailBase64.h
- classname: CBase64
- purpose: implement the base64 encoding mechanism
- *********************************************************************/
- class CBase64 : public CMIMECode
- {
- public:
- CBase64();
- virtual ~CBase64();
- ///<summary>
- /// decode the string
- ///</summary>
- ///<param name = >
- /// the string to be decoded
- ///</param>
- /// <returns>
- /// the decoding result
- /// </returns>
- virtual CString Decode(IN LPCTSTR szDecoding);
- ///<summary>
- /// encode the string
- ///</summary>
- ///<param name = szEncoding>
- /// the string to be encoded
- ///</param>
- ///<param name = nSize>
- /// the size of szEncoding
- ///</param>
- /// <returns>
- /// the encoding result
- /// </returns>
- virtual CString Encode(IN LPCTSTR szEncoding, IN int nSize);
- protected:
- ///<summary>
- /// Encode the string 3 byte one time
- ///</summary>
- ///<param name = szInBuf>
- /// the buffer to be encoded
- ///</param>
- ///<param name = szOutBuf>
- /// the result buffer
- ///</param>
- ///<param name = nRest>
- /// the remainder that is divided by 3
- ///</param>
- void EncodeEvery3Byte(IN LPCTSTR szInBuf, OUT LPTSTR szOutBuf, IN const int nRest = 0);
- ///<summary>
- /// Get 6 bits from the origin string
- ///</summary>
- ///<param name = szInBase>
- /// the origin string
- ///</param>
- ///<param name = nOffset>
- /// the index dictating which part to be processed
- ///</param>
- /// <returns>
- /// the result string
- /// </returns>
- char Get6Bits(IN LPCTSTR szInBase, IN const int nOffset);
- ///<summary>
- /// decode the string 4 byte one time
- ///</summary>
- ///<param name = szInBuf>
- /// the buffer to be decoded
- ///</param>
- ///<param name = szOutBuf>
- /// the result buffer
- ///</param>
- void DecodeEvery4Byte(IN LPCTSTR szInBuf, OUT LPTSTR szOutBuf);
- ///<summary>
- /// Set 6 bits to the destination string
- ///</summary>
- ///<param name = nOffset>
- /// the index dictating which part to be processed
- ///</param>
- ///<param name = n6Bits>
- /// the char to be processed
- ///</param>
- ///<param name = szOutBuf>
- /// the result buffer
- ///</param>
- void Set6Bits(IN const int nOffset, IN char n6Bits, OUT LPTSTR szOutBuf);
-
- ///<summary>
- /// a array for encoding, to help find char from xxxxxx
- ///</summary>
- char m_Arr[64];
- ///<summary>
- /// a Map for decoding,to help find xxxxxx from char
- ///</summary>
- CMap<char, char, char, char> m_Map;
- };