MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / EncodeBase64

Function EncodeBase64

src/util/strencodings.cpp:97–106  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

95}
96
97std::string EncodeBase64(std::span<const unsigned char> input)
98{
99 static const char *pbase64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
100
101 std::string str;
102 str.reserve(CeilDiv(input.size(), 3u) * 4);
103 ConvertBits<8, 6, true>([&](int v) { str += pbase64[v]; }, input.begin(), input.end());
104 while (str.size() % 4) str += '=';
105 return str;
106}
107
108std::optional<std::vector<unsigned char>> DecodeBase64(std::string_view str)
109{

Callers

nothing calls this directly

Calls 5

CeilDivFunction · 0.85
reserveMethod · 0.45
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected