1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-29 10:31:15 +02:00

Make hashLength32() a method of Hash

This commit is contained in:
Eelco Dolstra 2016-01-27 17:18:20 +01:00
parent 5b8c09c124
commit d45ad8fcf5
2 changed files with 15 additions and 12 deletions

View file

@ -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);