19 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
36 unsigned char *out, *pos;
37 const unsigned char *end, *in;
41 olen = len * 4 / 3 + 4;
54 while (end - in >= 3) {
56 *pos++ =
base64_table[((in[0] & 0x03) << 4) | (in[1] >> 4)];
57 *pos++ =
base64_table[((in[1] & 0x0f) << 2) | (in[2] >> 6)];
104 unsigned char dtable[256], *out, *pos, block[4], tmp;
105 size_t i,
count, olen;
108 memset(dtable, 0x80, 256);
114 for (i = 0; i < len; i++) {
115 if (dtable[src[i]] != 0x80)
122 olen =
count / 4 * 3;
129 for (i = 0; i < len; i++) {
130 tmp = dtable[src[i]];
139 *pos++ = (block[0] << 2) | (block[1] >> 4);
140 *pos++ = (block[1] << 4) | (block[2] >> 2);
141 *pos++ = (block[2] << 6) | block[3];
146 }
else if (pad == 2) {
158 *out_len = pos - out;
static const unsigned char base64_table[65]
unsigned char * base64_decode(const unsigned char *src, size_t len, size_t *out_len)
base64_decode - Base64 decode @src: Data to be decoded @len: Length of the data to be decoded @out_le...
unsigned char * base64_encode(const unsigned char *src, size_t len, size_t *out_len)
base64_encode - Base64 encode @src: Data to be encoded @len: Length of the data to be encoded @out_le...