Struct blake3::Hash

source · []
pub struct Hash(_);
Expand description

An output of the default size, 32 bytes, which provides constant-time equality checking.

Hash implements From and Into for [u8; 32], and it provides an explicit as_bytes method returning &[u8; 32]. However, byte arrays and slices don’t provide constant-time equality checking, which is often a security requirement in software that handles private data. Hash doesn’t implement Deref or AsRef, to avoid situations where a type conversion happens implicitly and the constant-time property is accidentally lost.

Hash provides the to_hex and from_hex methods for converting to and from hexadecimal. It also implements Display and FromStr.

Implementations

The raw bytes of the Hash. Note that byte arrays don’t provide constant-time equality checking, so if you need to compare hashes, prefer the Hash type.

Encode a Hash in lowercase hexadecimal.

The returned ArrayString is a fixed size and doesn’t allocate memory on the heap. Note that ArrayString doesn’t provide constant-time equality checking, so if you need to compare hashes, prefer the Hash type.

Decode a Hash from hexadecimal. Both uppercase and lowercase ASCII bytes are supported.

Any byte outside the ranges '0'...'9', 'a'...'f', and 'A'...'F' results in an error. An input length other than 64 also results in an error.

Note that Hash also implements FromStr, so Hash::from_hex("...") is equivalent to "...".parse().

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Formats the value using the given formatter. Read more

Converts to this type from the input type.

Converts to this type from the input type.

The associated error which can be returned from parsing.

Parses a string s to return a value of this type. Read more

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

This implementation is constant-time.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This implementation is constant-time if the target is 32 bytes long.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This implementation is constant-time.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.