From b7f008fc353ea05c423fb571047144052ce691c3 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 16 Nov 2005 08:27:06 +0000 Subject: * Did something useful while waiting at IAD: reference scanning is now much faster. --- src/libutil/hash.cc | 6 +++++- src/libutil/hash.hh | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'src/libutil') diff --git a/src/libutil/hash.cc b/src/libutil/hash.cc index 271e63665b..71d4ba67e2 100644 --- a/src/libutil/hash.cc +++ b/src/libutil/hash.cc @@ -109,13 +109,15 @@ static unsigned char divMod(unsigned char * bytes, unsigned char y) // omitted: E O U T -char chars[] = "0123456789abcdfghijklmnpqrsvwxyz"; +const string base32Chars = "0123456789abcdfghijklmnpqrsvwxyz"; string printHash32(const Hash & hash) { Hash hash2(hash); unsigned int len = (hash.hashSize * 8 - 1) / 5 + 1; + + const char * chars = base32Chars.c_str(); string s(len, '0'); @@ -165,6 +167,8 @@ Hash parseHash32(HashType ht, const string & s) { Hash hash(ht); + const char * chars = base32Chars.c_str(); + for (unsigned int i = 0; i < s.length(); ++i) { char c = s[i]; unsigned char digit; diff --git a/src/libutil/hash.hh b/src/libutil/hash.hh index 398b174216..0a0dfed7ee 100644 --- a/src/libutil/hash.hh +++ b/src/libutil/hash.hh @@ -15,6 +15,8 @@ const int md5HashSize = 16; const int sha1HashSize = 20; const int sha256HashSize = 32; +extern const string base32Chars; + struct Hash { -- cgit 1.4.1