Trait Digest

Source
pub trait Digest: Clone + Sized {
    type Output: Copy + Eq + Sized + Send + AsRef<[u8]> + for<'a> TryFrom<&'a [u8]> + Debug;

    const DIGEST_NAME: &'static str;
    const OUTPUT_LEN: usize;
    const BLOCK_LEN: usize;

    // Required methods
    fn new() -> Self;
    fn input(&mut self, data: impl AsRef<[u8]>);
    fn finalize(self) -> Self::Output;

    // Provided methods
    fn with_output_slice(slice: &[u8]) -> Option<Self> { ... }
    fn digest(data: impl AsRef<[u8]>) -> Self::Output { ... }
    fn digest_concat(
        data: impl IntoIterator<Item = impl AsRef<[u8]>>,
    ) -> Self::Output { ... }
}

Required Associated Constants§

Required Associated Types§

Source

type Output: Copy + Eq + Sized + Send + AsRef<[u8]> + for<'a> TryFrom<&'a [u8]> + Debug

Required Methods§

Source

fn new() -> Self

Source

fn input(&mut self, data: impl AsRef<[u8]>)

Source

fn finalize(self) -> Self::Output

Provided Methods§

Source

fn with_output_slice(slice: &[u8]) -> Option<Self>

Source

fn digest(data: impl AsRef<[u8]>) -> Self::Output

Source

fn digest_concat( data: impl IntoIterator<Item = impl AsRef<[u8]>>, ) -> Self::Output

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§

Source§

impl Digest for Sha256

Available on crate feature sha2 only.
Source§

const DIGEST_NAME: &'static str = "SHA256"

Source§

const OUTPUT_LEN: usize = 32usize

Source§

const BLOCK_LEN: usize = 64usize

Source§

type Output = [u8; 32]

Source§

impl<D: Digest> Digest for Hmac<D>

Source§

const DIGEST_NAME: &'static str = "HMAC"

Source§

const OUTPUT_LEN: usize = D::OUTPUT_LEN

Source§

const BLOCK_LEN: usize = D::BLOCK_LEN

Source§

type Output = <D as Digest>::Output