24     "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
    30     const std::vector<uint8_t>& inputData, std::string& outString)
    33     outString.reserve(inputData.size() * 
mrpt::round(4.0 / 3.0));
    39     for (
unsigned char c : inputData)
    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');
    89     const std::string& inString, std::vector<uint8_t>& outData)
    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--)
   102             decoder[
alphabet[i]] = 
static_cast<char>(i);
   107     outData.reserve(inString.size() * 
round(3.0 / 4.0));
   113     bool finish_flag_found = 
false;
   115     for (
unsigned char c : inString)
   119             finish_flag_found = 
true;
   122         if (!inalphabet[c]) 
continue;
   128             outData.push_back((bits >> 16));
   129             outData.push_back(((bits >> 8) & 0xff));
   130             outData.push_back((bits & 0xff));
   138     if (!finish_flag_found)
   142             std::cerr << 
"[decodeBase64] ERROR: base64 encoding incomplete, at"   144                       << ((4 - char_count) * 6) << 
"bits truncated."   154                 std::cerr << 
"[decodeBase64] ERROR: base64 encoding "   155                              "incomplete, at least 2 bits missing"   160                 outData.push_back((bits >> 10));
   163                 outData.push_back((bits >> 16));
   164                 outData.push_back(((bits >> 8) & 0xff));
 
bool decodeBase64(const std::string &inString, std::vector< uint8_t > &outData)
Decode a base-64 string into the original sequence of bytes. 
 
const unsigned char alphabet[64+1]
 
void encodeBase64(const std::vector< uint8_t > &inputData, std::string &outString)
Encode a sequence of bytes as a string in base-64. 
 
int round(const T value)
Returns the closer integer (int) to x.