Fix wrong hash string sometimes
This commit is contained in:
parent
7e48ee94c2
commit
3262ce8d25
1 changed files with 8 additions and 7 deletions
|
@ -68,18 +68,19 @@ namespace mchlib {
|
|||
std::string tiger_to_string_impl (const TigerHash& parHash) {
|
||||
typedef dhandy::ASCIITranslator<char, '0', (Upcase ? 'A' : 'a')> Ascii;
|
||||
|
||||
std::string retval(sizeof(uint64_t) * 2 * 3, '0');
|
||||
constexpr const std::size_t max_size = sizeof(uint64_t) * 2;
|
||||
std::string retval(max_size * 3, '0');
|
||||
{
|
||||
auto str_ary_a = dhandy::int_to_ary<uint64_t, 16, Ascii>(swap_long(parHash.part_a));
|
||||
std::copy(str_ary_a.begin(), str_ary_a.end(), retval.begin() + sizeof(uint64_t) * 2 * 1 - str_ary_a.size() + 1);
|
||||
auto ary = dhandy::int_to_ary<uint64_t, 16, Ascii>(swap_long(parHash.part_a));
|
||||
std::copy(ary.begin(), ary.begin() + ary.size() - 1, retval.begin() + max_size * 1 - ary.size() + 1);
|
||||
}
|
||||
{
|
||||
auto str_ary_b = dhandy::int_to_ary<uint64_t, 16, Ascii>(swap_long(parHash.part_b));
|
||||
std::copy(str_ary_b.begin(), str_ary_b.end(), retval.begin() + sizeof(uint64_t) * 2 * 2 - str_ary_b.size() + 1);
|
||||
auto ary = dhandy::int_to_ary<uint64_t, 16, Ascii>(swap_long(parHash.part_b));
|
||||
std::copy(ary.begin(), ary.begin() + ary.size() - 1, retval.begin() + max_size * 2 - ary.size() + 1);
|
||||
}
|
||||
{
|
||||
auto str_ary_c = dhandy::int_to_ary<uint64_t, 16, Ascii>(swap_long(parHash.part_c));
|
||||
std::copy(str_ary_c.begin(), str_ary_c.end(), retval.begin() + sizeof(uint64_t) * 2 * 3 - str_ary_c.size() + 1);
|
||||
auto ary = dhandy::int_to_ary<uint64_t, 16, Ascii>(swap_long(parHash.part_c));
|
||||
std::copy(ary.begin(), ary.begin() + ary.size() - 1, retval.begin() + max_size * 3 - ary.size() + 1);
|
||||
}
|
||||
|
||||
#if !defined(NDEBUG)
|
||||
|
|
Loading…
Reference in a new issue