diff options
author | Pieter Wuille <pieter@wuille.net> | 2022-04-04 13:19:49 -0400 |
---|---|---|
committer | MacroFake <falke.marco@gmail.com> | 2022-04-27 14:12:55 +0200 |
commit | a65931e3ce66d87b8f83d67ecdbb46f137e6a670 (patch) | |
tree | 1cdbaa2a15af7b87d7a963c4c759c2a29ddbe437 /src/util/strencodings.cpp | |
parent | a4377a0843636eae0aaf698510fc6518582545db (diff) |
Make DecodeBase{32,64} always return vector, not string
Base32/base64 are mechanisms for encoding binary data. That they'd
decode to a string is just bizarre. The fact that they'd do that
based on the type of input arguments even more so.
Diffstat (limited to 'src/util/strencodings.cpp')
-rw-r--r-- | src/util/strencodings.cpp | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/util/strencodings.cpp b/src/util/strencodings.cpp index 6b6644aa9f..a861885269 100644 --- a/src/util/strencodings.cpp +++ b/src/util/strencodings.cpp @@ -172,14 +172,13 @@ std::vector<unsigned char> DecodeBase64(const char* p, bool* pf_invalid) return ret; } -std::string DecodeBase64(const std::string& str, bool* pf_invalid) +std::vector<unsigned char> DecodeBase64(const std::string& str, bool* pf_invalid) { if (!ValidAsCString(str)) { *pf_invalid = true; return {}; } - std::vector<unsigned char> vchRet = DecodeBase64(str.c_str(), pf_invalid); - return std::string((const char*)vchRet.data(), vchRet.size()); + return DecodeBase64(str.c_str(), pf_invalid); } std::string EncodeBase32(Span<const unsigned char> input, bool pad) @@ -248,14 +247,13 @@ std::vector<unsigned char> DecodeBase32(const char* p, bool* pf_invalid) return ret; } -std::string DecodeBase32(const std::string& str, bool* pf_invalid) +std::vector<unsigned char> DecodeBase32(const std::string& str, bool* pf_invalid) { if (!ValidAsCString(str)) { *pf_invalid = true; return {}; } - std::vector<unsigned char> vchRet = DecodeBase32(str.c_str(), pf_invalid); - return std::string((const char*)vchRet.data(), vchRet.size()); + return DecodeBase32(str.c_str(), pf_invalid); } namespace { |