20 #include <ripple/basics/safe_cast.h>
21 #include <ripple/protocol/digest.h>
22 #include <ripple/protocol/tokens.h>
23 #include <boost/container/small_vector.hpp>
34 "rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz";
45 template <
class Hasher>
46 static typename Hasher::result_type
51 return static_cast<typename Hasher::result_type
>(h);
59 static typename Hasher::result_type
62 return digest<Hasher>(v.
data(), v.
size());
66 template <
class Hasher,
class... Args>
67 static typename Hasher::result_type
70 return digest<Hasher>(digest<Hasher>(args...));
85 auto const h = digest2<sha256_hasher>(message, size);
105 auto pbegin =
reinterpret_cast<unsigned char const*
>(message);
106 auto const pend = pbegin + size;
110 while (pbegin != pend && *pbegin == 0)
116 auto const b58begin =
reinterpret_cast<unsigned char*
>(temp);
117 auto const b58end = b58begin + temp_size;
121 while (pbegin != pend)
125 for (
auto iter = b58end; iter != b58begin; --iter)
127 carry += 256 * (iter[-1]);
128 iter[-1] = carry % 58;
136 auto iter = b58begin;
137 while (iter != b58end && *iter == 0)
142 str.
reserve(zeroes + (b58end - iter));
144 while (iter != b58end)
152 auto psz =
reinterpret_cast<unsigned char const*
>(s.
c_str());
153 auto remain = s.
size();
175 for (
auto iter = b256.
rbegin(); iter != b256.
rend(); ++iter)
187 b256.
begin(), b256.
end(), [](
unsigned char c) { return c != 0; });
190 result.
assign(zeroes, 0x00);
191 while (iter != b256.
end())
202 auto const expanded = 1 + size + 4;
207 auto const bufsize = expanded * 3;
209 boost::container::small_vector<std::uint8_t, 1024> buf(bufsize);
213 buf[0] = safe_cast<std::underlying_type_t<TokenType>>(type);
216 checksum(buf.data() + 1 + size, buf.data(), 1 + size);
219 buf.data(), expanded, buf.data() + expanded, bufsize - expanded);
232 if (type != safe_cast<TokenType>(
static_cast<std::uint8_t>(ret[0])))