Changeset View
Changeset View
Standalone View
Standalone View
src/utilstrencodings.cpp
Show First 20 Lines • Show All 264 Lines • ▼ Show 20 Lines | if (pfInvalid) { | ||||
} | } | ||||
} | } | ||||
return vchRet; | return vchRet; | ||||
} | } | ||||
std::string DecodeBase64(const std::string &str) { | std::string DecodeBase64(const std::string &str) { | ||||
std::vector<uint8_t> vchRet = DecodeBase64(str.c_str()); | std::vector<uint8_t> vchRet = DecodeBase64(str.c_str()); | ||||
return (vchRet.size() == 0) | return std::string((const char *)vchRet.data(), vchRet.size()); | ||||
? std::string() | |||||
: std::string((const char *)&vchRet[0], vchRet.size()); | |||||
} | } | ||||
std::string EncodeBase32(const uint8_t *pch, size_t len) { | std::string EncodeBase32(const uint8_t *pch, size_t len) { | ||||
static const char *pbase32 = "abcdefghijklmnopqrstuvwxyz234567"; | static const char *pbase32 = "abcdefghijklmnopqrstuvwxyz234567"; | ||||
std::string strRet = ""; | std::string strRet = ""; | ||||
strRet.reserve((len + 4) / 5 * 8); | strRet.reserve((len + 4) / 5 * 8); | ||||
▲ Show 20 Lines • Show All 172 Lines • ▼ Show 20 Lines | if (pfInvalid) switch (mode) { | ||||
break; | break; | ||||
} | } | ||||
return vchRet; | return vchRet; | ||||
} | } | ||||
std::string DecodeBase32(const std::string &str) { | std::string DecodeBase32(const std::string &str) { | ||||
std::vector<uint8_t> vchRet = DecodeBase32(str.c_str()); | std::vector<uint8_t> vchRet = DecodeBase32(str.c_str()); | ||||
return (vchRet.size() == 0) | return std::string((const char *)vchRet.data(), vchRet.size()); | ||||
? std::string() | |||||
: std::string((const char *)&vchRet[0], vchRet.size()); | |||||
} | } | ||||
static bool ParsePrechecks(const std::string &str) { | static bool ParsePrechecks(const std::string &str) { | ||||
// No empty string allowed | // No empty string allowed | ||||
if (str.empty()) { | if (str.empty()) { | ||||
return false; | return false; | ||||
} | } | ||||
// No padding allowed | // No padding allowed | ||||
▲ Show 20 Lines • Show All 343 Lines • Show Last 20 Lines |