pub trait FixedLenHasher<T>
where Self: Sized,
{ type Digest; // Required methods fn new(msg_len: u64) -> Self; fn update(&mut self, data: impl AsRef<[T]>); fn chain_update(self, data: impl AsRef<[T]>) -> Self; fn finalize(self) -> Result<Self::Digest, HashError>; fn reset(&mut self); }
Expand description

Trait representing a family of fixed-length cryptographic hash functions which is generic over the input type.

A fixed-length hash has the property that the amount of data in the preimage is fixed, and so must be specified up front when constructing the hasher. The [FixedLenHasher::finalize] will fail if the amount of data the hasher is updated with does not match the specified length. A family of fixed-length hash functions retains the property that is it impossible to find collisions between any two inputs, even those differing in length.

This interface is otherwise similar to the Hasher trait.

Required Associated Types§

source

type Digest

The hash function output type.

Required Methods§

source

fn new(msg_len: u64) -> Self

Constructor.

msg_len is the total number of T elements to be hashed

source

fn update(&mut self, data: impl AsRef<[T]>)

source

fn chain_update(self, data: impl AsRef<[T]>) -> Self

source

fn finalize(self) -> Result<Self::Digest, HashError>

source

fn reset(&mut self)

Resets with length initialized to the current context

Object Safety§

This trait is not object safe.

Implementors§