18 static constexpr
char Table[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
19 "abcdefghijklmnopqrstuvwxyz"
24 std::string &buffer) {
25 const char *data =
static_cast<const char *
>(dataIn);
26 buffer.resize(((size + 2) / 3) * 4);
29 for (
size_t n = size / 3 * 3; i < n; i += 3, j += 4) {
30 uint32_t x = ((
unsigned char)data[i] << 16) |
31 ((
unsigned char)data[i + 1] << 8) | (
unsigned char)data[i + 2];
32 buffer[j + 0] =
Table[(x >> 18) & 63];
33 buffer[j + 1] =
Table[(x >> 12) & 63];
34 buffer[j + 2] =
Table[(x >> 6) & 63];
35 buffer[j + 3] =
Table[x & 63];
38 uint32_t x = ((
unsigned char)data[i] << 16);
39 buffer[j + 0] =
Table[(x >> 18) & 63];
40 buffer[j + 1] =
Table[(x >> 12) & 63];
43 }
else if (i + 2 == size) {
45 ((
unsigned char)data[i] << 16) | ((
unsigned char)data[i + 1] << 8);
46 buffer[j + 0] =
Table[(x >> 18) & 63];
47 buffer[j + 1] =
Table[(x >> 12) & 63];
48 buffer[j + 2] =
Table[(x >> 6) & 63];
static constexpr char Table[]
void encodeBase64(const void *data, size_t size, std::string &out)