From d45ad8fcf5e79d95c55ed2185351d4e20d940cb2 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 27 Jan 2016 17:18:20 +0100 Subject: Make hashLength32() a method of Hash --- src/libutil/hash.hh | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src/libutil/hash.hh') diff --git a/src/libutil/hash.hh b/src/libutil/hash.hh index 841b4cb2936c..8bd7e9f17f4f 100644 --- a/src/libutil/hash.hh +++ b/src/libutil/hash.hh @@ -40,6 +40,18 @@ struct Hash /* For sorting. */ bool operator < (const Hash & h) const; + + /* Returns the length of a base-16 representation of this hash. */ + size_t base16Len() const + { + return hashSize * 2; + } + + /* Returns the length of a base-32 representation of this hash. */ + size_t base32Len() const + { + return (hashSize * 8 - 1) / 5 + 1; + } }; @@ -49,9 +61,6 @@ string printHash(const Hash & hash); /* Parse a hexadecimal representation of a hash code. */ Hash parseHash(HashType ht, const string & s); -/* Returns the length of a base-32 hash representation. */ -unsigned int hashLength32(const Hash & hash); - /* Convert a hash to a base-32 representation. */ string printHash32(const Hash & hash); -- cgit 1.4.1