HashFunction

Trait HashFunction 

Source
pub trait HashFunction {
    const OUTPUT_SIZE: usize;

    // Required method
    fn hash_to(data: &[u8], output: &mut [u8]);

    // Provided method
    fn hash(data: &[u8]) -> Vec<u8>  { ... }
}
Expand description

Hash algorithm trait providing a unified interface for different hash algorithms

Required Associated Constants§

Source

const OUTPUT_SIZE: usize

Hash output size (in bytes)

Required Methods§

Source

fn hash_to(data: &[u8], output: &mut [u8])

Compute hash to provided buffer (zero-allocation)

§Parameters
  • output: Must be at least OUTPUT_SIZE bytes
§Panics

Panics if output buffer is too small

Provided Methods§

Source

fn hash(data: &[u8]) -> Vec<u8>

Compute hash in one operation

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§