MCPcopy Create free account
hub / github.com/NGSolve/ngsolve / base64_encode

Function base64_encode

comp/webgui.cpp:10–30  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8namespace webgui {
9
10static std::string base64_encode(FlatArray<unsigned char> in) {
11 std::string out;
12
13 int val = 0, valb = -6;
14 for (unsigned char c : in) {
15 val = (val << 8) + c;
16 valb += 8;
17 while (valb >= 0) {
18 out.push_back(
19 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
20 [(val >> valb) & 0x3F]);
21 valb -= 6;
22 }
23 }
24 if (valb > -6)
25 out.push_back(
26 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
27 [((val << 8) >> (valb + 8)) & 0x3F]);
28 while (out.size() % 4) out.push_back('=');
29 return out;
30}
31
32double factorial(int n) { return std::tgamma(n + 1); }
33

Callers 2

MapBernsteinFunction · 0.85
GenerateVolumeDataFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected