38 'A',
'B',
'C',
'D',
'E',
'F',
'G',
'H',
'I',
'J',
'K',
'L',
'M',
39 'N',
'O',
'P',
'Q',
'R',
'S',
'T',
'U',
'V',
'W',
'X',
'Y',
'Z',
40 'a',
'b',
'c',
'd',
'e',
'f',
'g',
'h',
'i',
'j',
'k',
'l',
'm',
41 'n',
'o',
'p',
'q',
'r',
's',
't',
'u',
'v',
'w',
'x',
'y',
'z',
42 '0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9',
'+',
'/',
'\0'
50 if (
string ==
nullptr)
52 const unsigned char *current = string;
54 unsigned char *
const result =
static_cast<unsigned char *
>(
55 calloc(
CAST_SIZE((length + 3 - length % 3) * 4 / 3 + 1)
56 *
sizeof(
unsigned char), 1));
57 if (result ==
nullptr)
64 << 4) + (current[1] >> 4)];
66 << 2) + (current[2] >> 6)];
91 if (ret_length !=
nullptr)
104 const unsigned char *current = string;
110 unsigned char *result =
static_cast<unsigned char *
>(
111 calloc(length + 1, 1));
113 if (result ==
nullptr)
117 while ((ch = *current++) !=
'\0')
129 if (ch ==
' ') ch =
'+';
142 result[j++] |=
CAST_U8(ch >> 4U);
143 result[j] =
CAST_U8((ch & 0x0f) << 4U);
146 result[j++] |=
CAST_U8(ch >>2U);
147 result[j] =
CAST_U8((ch & 0x03) << 6U);
180 if (ret_length !=
nullptr)
191 const unsigned char *
const str =
reinterpret_cast<unsigned char*
>(
192 const_cast<char*
>(value.c_str()));
196 return std::string();
198 value = std::string(
reinterpret_cast<char*
>(buf), sz);
206 const unsigned char *
const str =
reinterpret_cast<unsigned char*
>(
207 const_cast<char*
>(value.c_str()));
212 value = std::string(
reinterpret_cast<char*
>(buf), sz);
static const char base64_pad
unsigned char * php3_base64_encode(const unsigned char *const string, int length, int *const ret_length)
static char base64_table[]
unsigned char * php3_base64_decode(const unsigned char *const string, const int length, int *const ret_length)
std::string decodeBase64String(std::string value)
std::string encodeBase64String(std::string value)