14static const unsigned char base64_table[65] =
15"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
27 const char* end, * in;
31 olen = 4 * ((len + 2) / 3);
38 out = (
char*)&outStr[0];
43 while(end - in >= 3) {
44 *pos++ = base64_table[in[0] >> 2];
45 *pos++ = base64_table[((in[0] & 0x03) << 4) | (in[1] >> 4)];
46 *pos++ = base64_table[((in[1] & 0x0f) << 2) | (in[2] >> 6)];
47 *pos++ = base64_table[in[2] & 0x3f];
52 *pos++ = base64_table[in[0] >> 2];
54 *pos++ = base64_table[(in[0] & 0x03) << 4];
57 *pos++ = base64_table[((in[0] & 0x03) << 4) |
59 *pos++ = base64_table[(in[1] & 0x0f) << 2];
std::string base64_encode(const char *src, size_t len)