diff options
Diffstat (limited to 'src/libutil')
-rw-r--r-- | src/libutil/hash.cc | 6 | ||||
-rw-r--r-- | src/libutil/hash.hh | 3 |
2 files changed, 9 insertions, 0 deletions
diff --git a/src/libutil/hash.cc b/src/libutil/hash.cc index 697a6b475b13..de2c1ebd724f 100644 --- a/src/libutil/hash.cc +++ b/src/libutil/hash.cc @@ -153,6 +153,12 @@ string printHash32(const Hash & hash) } +string printHash16or32(const Hash & hash) +{ + return hash.type == htMD5 ? printHash(hash) : printHash32(hash); +} + + static bool mul(unsigned char * bytes, unsigned char y, int maxSize) { unsigned char carry = 0; diff --git a/src/libutil/hash.hh b/src/libutil/hash.hh index 781f517428d0..2c6f176ec74c 100644 --- a/src/libutil/hash.hh +++ b/src/libutil/hash.hh @@ -54,6 +54,9 @@ unsigned int hashLength32(const Hash & hash); /* Convert a hash to a base-32 representation. */ string printHash32(const Hash & hash); +/* Print a hash in base-16 if it's MD5, or base-32 otherwise. */ +string printHash16or32(const Hash & hash); + /* Parse a base-32 representation of a hash code. */ Hash parseHash32(HashType ht, const string & s); |