|
|
|
@ -201,20 +201,20 @@ std::string DecodeBase64(const std::string& str, bool* pf_invalid)
|
|
|
|
|
return std::string((const char*)vchRet.data(), vchRet.size());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::string EncodeBase32(const unsigned char* pch, size_t len)
|
|
|
|
|
std::string EncodeBase32(Span<const unsigned char> input)
|
|
|
|
|
{
|
|
|
|
|
static const char *pbase32 = "abcdefghijklmnopqrstuvwxyz234567";
|
|
|
|
|
|
|
|
|
|
std::string str;
|
|
|
|
|
str.reserve(((len + 4) / 5) * 8);
|
|
|
|
|
ConvertBits<8, 5, true>([&](int v) { str += pbase32[v]; }, pch, pch + len);
|
|
|
|
|
str.reserve(((input.size() + 4) / 5) * 8);
|
|
|
|
|
ConvertBits<8, 5, true>([&](int v) { str += pbase32[v]; }, input.begin(), input.end());
|
|
|
|
|
while (str.size() % 8) str += '=';
|
|
|
|
|
return str;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::string EncodeBase32(const std::string& str)
|
|
|
|
|
{
|
|
|
|
|
return EncodeBase32((const unsigned char*)str.data(), str.size());
|
|
|
|
|
return EncodeBase32(MakeUCharSpan(str));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::vector<unsigned char> DecodeBase32(const char* p, bool* pf_invalid)
|
|
|
|
|