pub struct Hasher(_);
Expand description

An incremental hash state that can accept any number of writes.

Examples

// Hash an input incrementally.
let mut hasher = kangarootwelve_xkcp::Hasher::new();
hasher.update(b"foo");
hasher.update(b"bar");
hasher.update(b"baz");
assert_eq!(hasher.finalize(), kangarootwelve_xkcp::hash(b"foobarbaz"));

// Extended output. OutputReader also implements Read and Seek.
let mut hasher = kangarootwelve_xkcp::Hasher::new();
hasher.update(b"foobarbaz");
let mut output = [0; 1000];
let mut output_reader = hasher.finalize_xof();
output_reader.squeeze(&mut output);
assert_eq!(&output[..32], kangarootwelve_xkcp::hash(b"foobarbaz").as_bytes());

Implementations

Construct a new Hasher for the regular hash function.

Add input bytes to the hash state. You can call this any number of times, until the Hasher is finalized.

Finalize the hash state and return the Hash of the input. This method is equivalent to finalize_custom with an empty customization string.

You can only finalize a Hasher once. Additional calls to any of the finalize methods will panic.

Finalize the hash state using the given customization string and return the Hash of the input.

You can only finalize a Hasher once. Additional calls to any of the finalize methods will panic.

Finalize the hash state and return an OutputReader, which can supply any number of output bytes. This method is equivalent to finalize_custom_xof with an empty customization string.

You can only finalize a Hasher once. Additional calls to any of the finalize methods will panic.

Finalize the hash state and return an OutputReader, which can supply any number of output bytes.

You can only finalize a Hasher once. Additional calls to any of the finalize methods will panic.

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
Returns the “default value” for a type. Read more

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
Uses borrowed data to replace owned data, usually by cloning. 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.