Nix 2.93.3
Lix: A modern, delicious implementation of the Nix package manager; unstable internal interfaces
Loading...
Searching...
No Matches
nix::Hash Struct Reference

Public Member Functions

 Hash (HashType type)
bool operator== (const Hash &h2) const
bool operator!= (const Hash &h2) const
bool operator< (const Hash &h) const
size_t base16Len () const
size_t base32Len () const
size_t base64Len () const
std::string to_string (Base base, bool includeType) const
std::string gitRev () const
std::string gitShortRev () const

Static Public Member Functions

static Hash parseAny (std::string_view s, std::optional< HashType > type)
static Hash parseAnyPrefixed (std::string_view s)
static Hash parseNonSRIUnprefixed (std::string_view s, HashType type)
static Hash parseSRI (std::string_view original)

Public Attributes

size_t hashSize = 0
uint8_t hash [maxHashSize] = {}
HashType type

Static Public Attributes

static constexpr size_t maxHashSize = 64
static Hash dummy

Constructor & Destructor Documentation

◆ Hash()

nix::Hash::Hash ( HashType type)

Create a zero-filled hash object.

Member Function Documentation

◆ base16Len()

size_t nix::Hash::base16Len ( ) const
inline

Returns the length of a base-16 representation of this hash.

◆ base32Len()

size_t nix::Hash::base32Len ( ) const
inline

Returns the length of a base-32 representation of this hash.

◆ base64Len()

size_t nix::Hash::base64Len ( ) const
inline

Returns the length of a base-64 representation of this hash.

◆ operator!=()

bool nix::Hash::operator!= ( const Hash & h2) const

Check whether two hash are not equal.

◆ operator<()

bool nix::Hash::operator< ( const Hash & h) const

For sorting.

◆ operator==()

bool nix::Hash::operator== ( const Hash & h2) const

Check whether two hash are equal.

◆ parseAny()

Hash nix::Hash::parseAny ( std::string_view s,
std::optional< HashType > type )
static

Parse the hash from a string representation in the format "[<type>:]<base16|base32|base64>" or "<type>-<base64>" (a Subresource Integrity hash expression). If the 'type' argument is not present, then the hash type must be specified in the string.

◆ parseAnyPrefixed()

Hash nix::Hash::parseAnyPrefixed ( std::string_view s)
static

Parse a hash from a string representation like the above, except the type prefix is mandatory is there is no separate arguement.

◆ parseNonSRIUnprefixed()

Hash nix::Hash::parseNonSRIUnprefixed ( std::string_view s,
HashType type )
static

Parse a plain hash that musst not have any prefix indicating the type. The type is passed in to disambiguate.

◆ to_string()

std::string nix::Hash::to_string ( Base base,
bool includeType ) const

Return a string representation of the hash, in base-16, base-32 or base-64. By default, this is prefixed by the hash type (e.g. "sha256:").


The documentation for this struct was generated from the following files:
  • lix/libutil/hash.hh
  • lix/libutil/hash.cc