Go to the source code of this file.
Classes | |
struct | nix::Hash |
struct | nix::AbstractHashSink |
class | nix::HashSink |
Typedefs | |
typedef std::pair< Hash, uint64_t > | nix::HashResult |
Enumerations | |
enum struct | HashAlgorithm : char { MD5 = 42 , SHA1 , SHA256 , SHA512 } |
enum struct | nix::HashFormat : int { Base64 , Nix32 , Base16 , SRI } |
Enumeration representing the hash formats. More... | |
Functions | |
nix::MakeError (BadHash, Error) | |
Hash | nix::newHashAllowEmpty (std::string_view hashStr, std::optional< HashAlgorithm > ha) |
std::string | nix::printHash16or32 (const Hash &hash) |
Hash | nix::hashString (HashAlgorithm ha, std::string_view s) |
Hash | nix::hashFile (HashAlgorithm ha, const Path &path) |
Hash | nix::compressHash (const Hash &hash, unsigned int newSize) |
HashFormat | nix::parseHashFormat (std::string_view hashFormatName) |
std::optional< HashFormat > | nix::parseHashFormatOpt (std::string_view hashFormatName) |
std::string_view | nix::printHashFormat (HashFormat HashFormat) |
HashAlgorithm | nix::parseHashAlgo (std::string_view s) |
std::optional< HashAlgorithm > | nix::parseHashAlgoOpt (std::string_view s) |
std::string_view | nix::printHashAlgo (HashAlgorithm ha) |
Variables | |
const int | nix::md5HashSize = 16 |
const int | nix::sha1HashSize = 20 |
const int | nix::sha256HashSize = 32 |
const int | nix::sha512HashSize = 64 |
typedef std::pair<Hash, uint64_t> nix::HashResult |
The final hash and the number of bytes digested.
|
strong |
Enumeration representing the hash formats.
Enumerator | |
---|---|
Base64 | Base 64 encoding.
|
Nix32 | Nix-specific base-32 encoding.
|
Base16 | Lowercase hexadecimal encoding.
|
SRI | "<hash algo>:<Base 64 hash>", format of the SRI integrity attribute.
|
Compress a hash to the specified number of bytes by cyclically XORing bytes together.
Compute the hash of the given file, hashing its contents directly.
(Metadata, such as the executable permission bit, is ignored.)
Hash nix::hashString | ( | HashAlgorithm | ha, |
std::string_view | s ) |
Compute the hash of the given string.
Hash nix::newHashAllowEmpty | ( | std::string_view | hashStr, |
std::optional< HashAlgorithm > | ha ) |
Helper that defaults empty hashes to the 0 hash.
HashAlgorithm nix::parseHashAlgo | ( | std::string_view | s | ) |
Parse a string representing a hash algorithm.
std::optional< HashAlgorithm > nix::parseHashAlgoOpt | ( | std::string_view | s | ) |
Will return nothing on parse error
HashFormat nix::parseHashFormat | ( | std::string_view | hashFormatName | ) |
Parse a string representing a hash format.
std::optional< HashFormat > nix::parseHashFormatOpt | ( | std::string_view | hashFormatName | ) |
std::optional version of parseHashFormat that doesn't throw error.
std::string nix::printHash16or32 | ( | const Hash & | hash | ) |
Print a hash in base-16 if it's MD5, or base-32 otherwise.
std::string_view nix::printHashAlgo | ( | HashAlgorithm | ha | ) |
And the reverse.
std::string_view nix::printHashFormat | ( | HashFormat | hashFormat | ) |
The reverse of parseHashFormat.