00001 00002 // Filename: Base64.h 00003 // Author: Matt Cooper (mcooper@orionsec.com) 00004 // Last Modification Time: 6/9/2004 17:56 00006 00014 #if !defined(CBASE64_H_INCLUDED) 00015 #define CBASE64_H_INCLUDED 00016 00021 class CBase64Buffer 00022 { 00023 public: 00024 CBase64Buffer(); 00025 virtual ~CBase64Buffer(); 00026 00027 bool decode( const char *in, const unsigned long inLen, unsigned char *out, unsigned long *outLen ); 00028 bool encode( const unsigned char *in, const unsigned long inLen, char *out, unsigned long *outLen ); 00029 00030 void addLineBreaks( int addLineBreaksAt, bool addCarriageReturn = true ); // should be 0 for none or evenly divisible by 4 00031 bool prependChars(const char *sz); // places supplied characters at front of each new line. 3 char max 00032 00033 protected: 00034 int m_addLineBreaks; 00035 char* m_prependChars; 00036 bool m_addCR; 00037 00038 static unsigned char m_base64chars[]; 00039 static unsigned int m_bitMask[]; 00040 static int m_decodeTable[]; 00041 }; 00042 00043 #endif //CBASE64_H_INCLUDED