Hash

Trait Hash 

pub trait Hash: Send + Sync {
    // Required methods
    fn start(&self) -> Box<dyn Context>;
    fn hash(&self, data: &[u8]) -> Output;
    fn output_len(&self) -> usize;
    fn algorithm(&self) -> HashAlgorithm;

    // Provided method
    fn fips(&self) -> bool { ... }
}
Available on crate feature tls only.
Expand description

Describes a single cryptographic hash function.

This interface can do both one-shot and incremental hashing, using Hash::hash() and Hash::start() respectively.

Required Methods§

fn start(&self) -> Box<dyn Context>

Start an incremental hash computation.

fn hash(&self, data: &[u8]) -> Output

Return the output of this hash function with input data.

fn output_len(&self) -> usize

The length in bytes of this hash function’s output.

fn algorithm(&self) -> HashAlgorithm

Which hash function this is, eg, HashAlgorithm::SHA256.

Provided Methods§

fn fips(&self) -> bool

Return true if this is backed by a FIPS-approved implementation.

Implementors§