mundane::hash

Trait Hasher

Source
pub trait Hasher:
    Default
    + Clone
    + Hasher
    + Hasher {
    type Digest: Digest;

    // Required methods
    fn update(&mut self, bytes: &[u8]);
    fn finish(self) -> Self::Digest;

    // Provided method
    fn hash(bytes: &[u8]) -> Self::Digest { ... }
}
Expand description

A cryptographic hash function.

Required Associated Types§

Source

type Digest: Digest

The output digest.

Required Methods§

Source

fn update(&mut self, bytes: &[u8])

Adds bytes to the hash.

Source

fn finish(self) -> Self::Digest

Returns the digest of the bytes added so far.

Provided Methods§

Source

fn hash(bytes: &[u8]) -> Self::Digest

Computes the hash of a sequence of bytes.

hash creates a new instance of this hash function, adds bytes to it, and then computes the digest.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§