MCPcopy Create free account
hub / github.com/GlobalTechInfo/MEGA-MD / b64encode

Function b64encode

lib/rle.cpp:12–26  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10static const std::string B64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
11
12std::string b64encode(const std::string& in) {
13 std::string out;
14 int val = 0, valb = -6;
15 for (unsigned char c : in) {
16 val = (val << 8) + c;
17 valb += 8;
18 while (valb >= 0) {
19 out += B64[(val >> valb) & 0x3F];
20 valb -= 6;
21 }
22 }
23 if (valb > -6) out += B64[((val << 8) >> (valb + 8)) & 0x3F];
24 while (out.size() % 4) out += '=';
25 return out;
26}
27
28std::string b64decode(const std::string& in) {
29 std::string out;

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected