32 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
33 "abcdefghijklmnopqrstuvwxyz"
36 static inline bool is_base64(
unsigned char c) {
return (isalnum(
c) || (
c ==
'+') || (
c ==
'/')); }
42 unsigned char char_array_3[3];
43 unsigned char char_array_4[4];
46 char_array_3[
i++] = *(bytes_to_encode++);
48 char_array_4[0] = (char_array_3[0] & 0xfc) >> 2;
49 char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4);
50 char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6);
51 char_array_4[3] = char_array_3[2] & 0x3f;
53 for (
i = 0; (
i < 4);
i++)
60 for (
j =
i;
j < 3;
j++)
61 char_array_3[
j] =
'\0';
63 char_array_4[0] = (char_array_3[0] & 0xfc) >> 2;
64 char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4);
65 char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6);
66 char_array_4[3] = char_array_3[2] & 0x3f;
68 for (
j = 0; (
j <
i + 1);
j++)
79 int in_len = encoded_string.size();
83 unsigned char char_array_4[4], char_array_3[3];
86 while (in_len-- && (encoded_string[in_] !=
'=') &&
is_base64(encoded_string[in_])) {
87 char_array_4[
i++] = encoded_string[in_];
90 for (
i = 0;
i < 4;
i++)
93 char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
94 char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
95 char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];
97 for (
i = 0; (
i < 3);
i++)
98 ret += char_array_3[
i];
104 for (
j =
i;
j < 4;
j++)
107 for (
j = 0;
j < 4;
j++)
110 char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
111 char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
112 char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];
114 for (
j = 0; (
j <
i - 1);
j++)
115 ret += char_array_3[
j];