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§
Required Methods§
sourcefn new(msg_len: u64) -> Self
fn new(msg_len: u64) -> Self
Constructor.
msg_len
is the total number of T
elements to be hashed
fn update(&mut self, data: impl AsRef<[T]>)
fn chain_update(self, data: impl AsRef<[T]>) -> Self
fn finalize(self) -> Result<Self::Digest, HashError>
Object Safety§
This trait is not object safe.