Skip to main content

Digest

Trait Digest 

Source
pub trait Digest:
    Algorithm
    + Clone
    + Default {
    type Output: AsRef<[u8]> + AsMut<[u8]> + Copy;

    const OUTPUT_LEN: usize;
    const BLOCK_LEN: usize;

    // Required methods
    fn update(&mut self, data: &[u8]);
    fn finalize(self) -> Self::Output;

    // Provided methods
    fn new() -> Self { ... }
    fn digest(data: &[u8]) -> Self::Output { ... }
}
Expand description

A cryptographic hash function with a fixed-length output.

Required Associated Constants§

Source

const OUTPUT_LEN: usize

Output length in bytes.

Source

const BLOCK_LEN: usize

Internal block (rate) length in bytes — required by HMAC and KMAC.

Required Associated Types§

Source

type Output: AsRef<[u8]> + AsMut<[u8]> + Copy

The fixed-size output buffer type, e.g. [u8; 32].

Required Methods§

Source

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

Absorb more input. May be called any number of times.

Source

fn finalize(self) -> Self::Output

Consume the hasher and produce the digest.

Provided Methods§

Source

fn new() -> Self

Create a fresh, empty hasher.

Source

fn digest(data: &[u8]) -> Self::Output

One-shot convenience: hash data in a single call.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§