diff --git a/src/lib/hash-util.hh b/src/lib/hash-util.hh index 3f41fc6f..157d774c 100644 --- a/src/lib/hash-util.hh +++ b/src/lib/hash-util.hh @@ -21,7 +21,6 @@ #include #include -#include /// compute TEng hash of `src` and return it as hex-encoded string template @@ -31,19 +30,18 @@ std::string hexHashStr(const TSrc &src) TEng eng; eng.process_bytes(src.data(), src.size()); - // export the hash as an array of unsigned int - typename TEng::digest_type dst; + // export the hash as an array + using TDst = typename TEng::digest_type; + TDst dst; eng.get_digest(dst); - // convert the hash to a vector of unsigned int + // convert the hash to a vector static const size_t len = sizeof(dst) / sizeof(dst[0]); - const std::vector hash(dst, dst + len); + using TElem = typename std::remove_extent::type; + const std::vector hash(dst, dst + len); // convert the hash to a hex string std::string result; - boost::algorithm::hex(hash.begin(), hash.end(), back_inserter(result)); - - // convert uppercase letters to lowercase - boost::algorithm::to_lower(result); + boost::algorithm::hex_lower(hash.begin(), hash.end(), back_inserter(result)); return result; }