Skip to main content

Module hash_factory

Module hash_factory 

Source
Expand description

Hash factory for creating instances of algorithms that implement the Hash trait.

As with all Factory objects, this implements constructions from strings and defaults, and returns a HashFactory object which itself implements the Hash trait as a pass-through to the underlying algorithm.

Example usage:

use factory::AlgorithmFactory;
use core_interface::traits::Hash;

let data: &[u8] = b"Hello, world!";

let h = factory::hash_factory::HashFactory::new(sha3::SHA3_256_NAME).unwrap();
let output: Vec<u8> = h.hash(data);

You can equivalently invoke this by string instead of using the constant:

use factory::AlgorithmFactory;
use core_interface::traits::Hash;

let data: &[u8] = b"Hello, world!";

let h = factory::hash_factory::HashFactory::new("SHA3-256").unwrap();
let output: Vec<u8> = h.hash(data);

Enums§

HashFactory
All members must impl Hash. Note: no SHAKE because SHAKE is not NIST approved as a hash function. See FIPS 202 section A.2.

Constants§

DEFAULT_128BIT_HASH_NAME
DEFAULT_256BIT_HASH_NAME
DEFAULT_HASH_NAME