diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2008-12-03 16:10:17 +0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2008-12-03 16:10:17 +0000 |
commit | ff762fb499be220ccd680f3bf68dca44a902a5ff (patch) | |
tree | 02f738ec60517e3eadd5b0a2bc2fe5c19c3d954c /src/libutil | |
parent | 1307b222239da8e503d22ad9316789e30b4e2431 (diff) |
* Pass HashType values instead of strings.
Diffstat (limited to 'src/libutil')
-rw-r--r-- | src/libutil/hash.cc | 9 | ||||
-rw-r--r-- | src/libutil/hash.hh | 3 |
2 files changed, 12 insertions, 0 deletions
diff --git a/src/libutil/hash.cc b/src/libutil/hash.cc index 70604a50a..eef01fe4d 100644 --- a/src/libutil/hash.cc +++ b/src/libutil/hash.cc @@ -335,4 +335,13 @@ HashType parseHashType(const string & s) } +string printHashType(HashType ht) +{ + if (ht == htMD5) return "md5"; + else if (ht == htSHA1) return "sha1"; + else if (ht == htSHA256) return "sha256"; + else throw Error("cannot print unknown hash type"); +} + + } diff --git a/src/libutil/hash.hh b/src/libutil/hash.hh index c3932b11b..062d97254 100644 --- a/src/libutil/hash.hh +++ b/src/libutil/hash.hh @@ -82,6 +82,9 @@ Hash compressHash(const Hash & hash, unsigned int newSize); /* Parse a string representing a hash type. */ HashType parseHashType(const string & s); +/* And the reverse. */ +string printHashType(HashType ht); + union Ctx; |