#pragma once #include "types.hh" #include "serialise.hh" namespace nix { typedef enum { htUnknown, htMD5, htSHA1, htSHA256, htSHA512 } HashType; const int md5HashSize = 16; const int sha1HashSize = 20; const int sha256HashSize = 32; const int sha512HashSize = 64; extern const string base32Chars; struct Hash { static const unsigned int maxHashSize = 64; unsigned int hashSize; unsigned char hash[maxHashSize]; HashType type; /* Create an unusable hash object. */ Hash(); /* Create a zero-filled hash object. */ Hash(HashType type); /* Check whether two hash are equal. */ bool operator == (const Hash & h2) const; /* Check whether two hash are not equal. */ bool operator != (const Hash & h2) const; /* For sorting. */ bool operator < (const Hash & h) const; }; /* Convert a hash to a hexadecimal representation. */ 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
aboutsummaryrefslogtreecommitdiff
path: root/gnu/build/shepherd.scm
blob: d7b858dea435f38c0a4cfb5233be8ce88368583f (about) (plain)