about summary refs log tree commit diff
path: root/src/libutil/hash.hh
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2016-01-27T16·18+0100
committerEelco Dolstra <eelco.dolstra@logicblox.com>2016-01-27T16·18+0100
commitd45ad8fcf5e79d95c55ed2185351d4e20d940cb2 (patch)
tree7be7b57d4821a491b08e09bac44d14a04dd401af /src/libutil/hash.hh
parent5b8c09c1240ca0df3d451bb5cb95d88602efd341 (diff)
Make hashLength32() a method of Hash
Diffstat (limited to 'src/libutil/hash.hh')
-rw-r--r--src/libutil/hash.hh15
1 files changed, 12 insertions, 3 deletions
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);