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 bouncycastle_factory::AlgorithmFactory;
use bouncycastle_core::traits::Hash;
use bouncycastle_sha3 as sha3;

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

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

Equivalently, it may be invoked by passing a string instead of using the constant:

use bouncycastle_factory::AlgorithmFactory;
use bouncycastle_core::traits::Hash;

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

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

Enumsยง

HashFactory
Wrapper object for all algorithms that impl Hash. Note: no SHAKE because SHAKE is not NIST approved as a hash function. See FIPS 202 section A.2.