#include "config.h" #include #include #include "hash.hh" #include "archive.hh" #include "util.hh" #include #include #include namespace nix { Hash::Hash() { type = htUnknown; hashSize = 0; memset(hash, 0, maxHashSize); } Hash::Hash(HashType type) { this->type = type; hashSize = gcry_md_get_algo_dlen(type); if (hashSize == 0) throw Error("unknown hash type"); assert(hashSize <= maxHashSize); memset(hash, 0, maxHashSize); } bool Hash::operator == (const Hash & h2) const { if (hashSize != h2.hashSize) return false; for (unsigned int i = 0; i < hashSize; i++) if (hash[i] != h2.hash[i]) return false; return true; } bool Hash::operator != (const Hash & h2) const { return !(*this == h2); } bool Hash::operator < (const Hash & h) const { for (unsigned int i = 0; i < hashSize; i++) { if (hash[i] < h.hash[i]) return true; if (hash[i] > h.hash[i]) return false; } return false; } const string ba
aboutsummaryrefslogtreecommitdiff