23 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
38 for (
size_t i = 0; i < inputData.size(); i++)
46 outString.push_back(
alphabet[bits >> 18]);
47 outString.push_back(
alphabet[(bits >> 12) & 0x3f]);
48 outString.push_back(
alphabet[(bits >> 6) & 0x3f]);
49 outString.push_back(
alphabet[bits & 0x3f]);
53 outString.push_back(
'\n');
67 bits <<= 16 - (8 * char_count);
68 outString.push_back(
alphabet[bits >> 18]);
69 outString.push_back(
alphabet[(bits >> 12) & 0x3f]);
73 outString.push_back(
'=');
74 outString.push_back(
'=');
78 outString.push_back(
alphabet[(bits >> 6) & 0x3f]);
79 outString.push_back(
'=');
81 if (cols > 0) outString.push_back(
'\n');
91 static bool inalphabet[256];
92 static char decoder[256];
94 static bool tablesBuilt =
false;
99 for (
int i = (
sizeof(
alphabet)) - 1; i >= 0; i--)
107 outData.reserve(inString.size() *
round(3.0 / 4.0));
113 bool finish_flag_found =
false;
115 for (
size_t i = 0; i < inString.size(); i++)
117 const unsigned char c = inString[i];
121 finish_flag_found =
true;
124 if (!inalphabet[
c])
continue;
130 outData.push_back((bits >> 16));
131 outData.push_back(((bits >> 8) & 0xff));
132 outData.push_back((bits & 0xff));
140 if (!finish_flag_found)
145 "[decodeBase64] ERROR: base64 encoding " 146 "incomplete, at least %d bits truncated",
147 ((4 - char_count) * 6))
157 std::cerr <<
"[decodeBase64] ERROR: base64 encoding " 158 "incomplete, at least 2 bits missing" 163 outData.push_back((bits >> 10));
166 outData.push_back((bits >> 16));
167 outData.push_back(((bits >> 8) & 0xff));
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
std::vector< uint8_t > vector_byte
This namespace provides a OS-independent interface to many useful functions: filenames manipulation...
void encodeBase64(const vector_byte &inputData, std::string &outString)
Encode a sequence of bytes as a string in base-64.
bool decodeBase64(const std::string &inString, vector_byte &outData)
Decode a base-64 string into the original sequence of bytes.
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
GLsizei const GLchar ** string
const unsigned char alphabet[64+1]
int round(const T value)
Returns the closer integer (int) to x.