pub struct Hash { /* private fields */ }
Expand description

Crytographically secure hash of data.

Offers constant time equality check (non-constant time ordinal checks). A version byte is used to indicate what hash algorithm should be used. Uses base58 encoding when displayed, unless overridden with hex formatting or debug formatting.

Supported Versions

  • 1: Blake2B hash with 32 bytes of digest

Example

// Create a new hash from raw bytes
let hash = Hash::new(b"I am the entire data sequence");
println!("Hash(Base58): {}", hash);

Implementations

Create a new hash from raw data, using the recommended algorithm.

Create a hash with a specific algorithm version. You should avoid this except when working through a upgrade process, where you may briefly need to support more than one version. Fails if the version isn’t supported.

Algorithm version associated with this hash.

The raw digest from the hash, without the version byte.

Attempt to parse a Base58-encoded hash type. Fails if the string isn’t valid Base58 or the hash itself isn’t valid.

Encode the hash as a Base58 string.

Trait Implementations

Performs the conversion.

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Determine if two items are equal. Read more

Formats the value using the given formatter. Read more

Deserialize this value from the given Serde deserializer. Read more

Formats the value using the given formatter. Read more

Feeds this value into the given Hasher. Read more

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

Formats the value using the given formatter.

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

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

This method tests for !=.

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Serialize this value into the given Serde serializer. Read more

The type returned in the event of a conversion error.

Performs the conversion.

Formats the value using the given formatter.

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

Performs the conversion.

Performs the conversion.

Should always be Self

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.