Trait cypher::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 Types§

source

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

Required Associated Constants§

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

Object Safety§

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

§

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

§

type Output = <D as Digest>::Output