27 const char *base64_char_cstr = 
"ABCDEFGHIJKLMNOPQRSTUVWXYZ" 
   28                                "abcdefghijklmnopqrstuvwxyz" 
   35     unsigned char out_byte1, out_byte2, out_byte3, out_byte4;
 
   36     unsigned char in_byte1, in_byte2, in_byte3;
 
   38     const std::string base64_chars = base64_char_cstr ;
 
   40     std::ostringstream outStr;
 
   41     int remainder = string_size%3;
 
   43     int test = string_size - remainder;
 
   46         in_byte1 = *(bytes++);
 
   47         in_byte2 = *(bytes++);
 
   48         in_byte3 = *(bytes++);
 
   49         out_byte1 = (in_byte1 >> 2);
 
   50         out_byte2 = (in_byte1 & 0x03) << 4 | (in_byte2 >> 4);
 
   51         out_byte3 = (in_byte2 & 0x0f) << 2 | (in_byte3 >> 6);
 
   52         out_byte4 = in_byte3 & 0x3f;
 
   53         outStr << base64_chars[out_byte1];
 
   54         outStr <<  base64_chars[out_byte2];
 
   55         outStr << base64_chars[out_byte3];
 
   56         outStr << base64_chars[out_byte4]  ;
 
   62         in_byte1 = *(bytes++);
 
   64         out_byte1 = (in_byte1 >> 2);
 
   65         outStr << base64_chars[out_byte1];
 
   69             out_byte2 = (in_byte1 & 0x03) << 4 | (in_byte2 >> 4);
 
   70             outStr <<  base64_chars[out_byte2];
 
   75             in_byte2 = *(bytes++);
 
   76             out_byte2 = (in_byte1 & 0x03) << 4 | (in_byte2 >> 4);
 
   77             out_byte3 = (in_byte2 & 0x0f) << 2 | (in_byte3 >> 6);
 
   78             outStr <<  base64_chars[out_byte2];
 
   79             outStr << base64_chars[out_byte3];
 
   89     unsigned char out_byte1, out_byte2, out_byte3;
 
   90     unsigned char in_byte1, in_byte2, in_byte3, in_byte4;
 
   91     std::ostringstream outStr;
 
   93     const std::string base64_chars = base64_char_cstr ;
 
   96     while(*b64bytes != 
'=' && *b64bytes != 
'\0')
 
   98         in_byte1 = base64_chars.find(*(b64bytes++));
 
   99         in_byte2 = base64_chars.find(*(b64bytes++));
 
  100         in_byte3 = base64_chars.find(*(b64bytes++));
 
  101         in_byte4 = base64_chars.find(*(b64bytes++));
 
  102         out_byte1 = (in_byte1 << 2)  | ((in_byte2 & 0x30)  >> 4)  ;
 
  103         out_byte2 = ((in_byte2 & 0x0f) << 4)  | ((in_byte3 & 0x3c)  >> 2)  ;
 
  104         out_byte3 = ((in_byte3  & 0x03) << 6)  |  in_byte4  ;
 
  112         in_byte1 = base64_chars.find(*(b64bytes++));
 
  113         in_byte2 = base64_chars.find(*(b64bytes++));
 
  115         out_byte1 = (in_byte1 << 2)  | ((in_byte2 & 0x30)  >> 4)  ;
 
  118         if(*b64bytes == 
'\0')  
 
  120             in_byte3 = base64_chars.find(*(b64bytes++));
 
  121             out_byte2 = ((in_byte2 & 0x0f) << 4)  | ((in_byte3 & 0x3c)  >> 2)  ;
 
  122             out_byte3 = ((in_byte3  & 0x03) << 6)  |  in_byte4  ;
 
  128             out_byte2 = ((in_byte2 & 0x0f) << 4)  | ((in_byte3 & 0x3c)  >> 2)  ;
 
  129             out_byte3 = ((in_byte3  & 0x03) << 6)  |  in_byte4  ;
 
static std::string encodeb64(char *bytes, int size)
encode the data in base 64 
static std::string decodeb64(char *b64bytes)
decode the data in base 64