diff options
author | Vasil Dimov <vd@FreeBSD.org> | 2020-08-27 11:03:21 +0200 |
---|---|---|
committer | Vasil Dimov <vd@FreeBSD.org> | 2020-09-21 10:13:34 +0200 |
commit | 7be6ff61875a8d5d2335bff5d1f16ba40557adb0 (patch) | |
tree | a2c60b8c3ad2144f697f334c05b6f6a508743459 /src/util/strencodings.cpp | |
parent | e0d73573a37bf4b519f6f61e5678572d48a64517 (diff) | |
download | bitcoin-7be6ff61875a8d5d2335bff5d1f16ba40557adb0.tar.xz |
net: recognize TORv3/I2P/CJDNS networks
Recognizing addresses from those networks allows us to accept and gossip
them, even though we don't know how to connect to them (yet).
Co-authored-by: eriknylund <erik@daychanged.com>
Diffstat (limited to 'src/util/strencodings.cpp')
-rw-r--r-- | src/util/strencodings.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/util/strencodings.cpp b/src/util/strencodings.cpp index 079a4529a3..3236184b0b 100644 --- a/src/util/strencodings.cpp +++ b/src/util/strencodings.cpp @@ -201,20 +201,24 @@ std::string DecodeBase64(const std::string& str, bool* pf_invalid) return std::string((const char*)vchRet.data(), vchRet.size()); } -std::string EncodeBase32(Span<const unsigned char> input) +std::string EncodeBase32(Span<const unsigned char> input, bool pad) { static const char *pbase32 = "abcdefghijklmnopqrstuvwxyz234567"; std::string str; 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 += '='; + if (pad) { + while (str.size() % 8) { + str += '='; + } + } return str; } -std::string EncodeBase32(const std::string& str) +std::string EncodeBase32(const std::string& str, bool pad) { - return EncodeBase32(MakeUCharSpan(str)); + return EncodeBase32(MakeUCharSpan(str), pad); } std::vector<unsigned char> DecodeBase32(const char* p, bool* pf_invalid) |