00001 00010 // Base64Encoder.h: interface for the Base64Encoder class. 00011 // 00013 /* 00014 #if !defined(BASE64ENCODER_H) 00015 #include "Base64Encoder.h" 00016 #endif // !defined(BASE64ENCODER_H) 00017 */ 00018 #if !defined(BASE64ENCODER_H) 00019 #define BASE64ENCODER_H 00020 00021 #if _MSC_VER > 1000 00022 #pragma once 00023 #endif // _MSC_VER > 1000 00024 00025 #ifndef _STRING_ 00026 #include <string> 00027 #endif // _STRING_ 00028 00029 class Base64Encoder 00030 { 00031 public: 00032 // Constructor/ Destructor 00033 Base64Encoder(); 00034 virtual ~Base64Encoder(); 00035 00036 // encodeValue 00037 // Description: 00038 // Takes a series of bytes and base64 encodes them. 00039 // Arugments: 00040 // value: Pointer to the byte stream to encode. 00041 // ulSizeofValue: Number of bytes, starting at value, that 00042 // need to be encoded. 00043 // Return Value: 00044 // Returns a base64 representation of the data. 00045 std::string encodeValue( void* value, unsigned long ulSizeofValue ); 00046 00047 // decodeValue 00048 // Description: 00049 // Decodes the value from a base64 string to its original 00050 // binary form. 00051 // Arugments: 00052 // value: base64 encoded version of the data. 00053 // ulSizeOfValue: On return, indicates how many bytes are 00054 // pointed to by the return value. 00055 // Return Value: 00056 // Pointer to the decoded data. You need to know what to do with 00057 // it when it comes back (because I sure don't). 00058 unsigned char* decodeValue( const std::string& value, unsigned long& ulSizeofValue ); 00059 00060 private: 00061 00062 // m_lookupTable 00063 // Description: Every 6-bit field that can be mapped to an entry 00064 // in this table. 00065 static const unsigned char lookupTable[65]; 00066 00067 // m_lookdownTable 00068 // Description: Every byt field that can be mapped to an entry 00069 // in this table. 00070 static const unsigned char lookdownTable[256]; 00071 00072 // g_KsizeofBase64Buffer 00073 // Description: Constant to use for building the 00074 // buffer and encoding/decoding it (used by encodeBuffer 00075 // and decodeBuffer). 00076 static const int g_KsizeofBase64Buffer; 00077 }; 00078 00079 #endif // !defined(BASE64ENCODER_H)