about summary refs log tree commit diff
path: root/src/libutil/hash.cc
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2006-09-20T16·15+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2006-09-20T16·15+0000
commit0623359fbc67c421bf76b7433f92c7ef58050321 (patch)
treeb0621f97bbbea2ae2ad69a89284454aa1f0c85c0 /src/libutil/hash.cc
parent22d13d6ec27b02f98ca4e398fbae4f3273e97794 (diff)
* Print a better error message for wrong hashes (NIX-49).
Diffstat (limited to 'src/libutil/hash.cc')
-rw-r--r--src/libutil/hash.cc8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/libutil/hash.cc b/src/libutil/hash.cc
index 16597fd47cbf..7381948f2180 100644
--- a/src/libutil/hash.cc
+++ b/src/libutil/hash.cc
@@ -120,6 +120,12 @@ static unsigned char divMod(unsigned char * bytes, unsigned char y)
 }
 
 
+unsigned int hashLength32(const Hash & hash)
+{
+    return (hash.hashSize * 8 - 1) / 5 + 1;
+}
+
+
 // omitted: E O U T
 const string base32Chars = "0123456789abcdfghijklmnpqrsvwxyz";
 
@@ -127,7 +133,7 @@ const string base32Chars = "0123456789abcdfghijklmnpqrsvwxyz";
 string printHash32(const Hash & hash)
 {
     Hash hash2(hash);
-    unsigned int len = (hash.hashSize * 8 - 1) / 5 + 1;
+    unsigned int len = hashLength32(hash);
 
     const char * chars = base32Chars.c_str();