bab_rs 0.6.0

An implementation of the Bab family of hash functions, and its WILLIAM3 instantiation.
Documentation
use crate::{
    CHUNK_SIZE, HashChunkContext, HashInnerContext, WIDTH, William3Digest,
    generic::BabInstantiation, hash_chunk, hash_inner,
};

/// Computes the WILLIAM3 digest of the given input bytes, and writes it into `out`.
///
/// This is the simplemost hashing API; it requires the full string to be available at once. See the [William3`Hasher`](crate::William3Hasher) API for incremental hashing.
pub fn batch_hash(bytes: &[u8], out: &mut William3Digest) {
    let (hash_chunk_context, hash_inner_context) =
        (HashChunkContext::new(), HashInnerContext::new());

    let bab_instantiation = BabInstantiation {
        hash_chunk,
        hash_inner,
        hash_chunk_context,
        hash_inner_context,
    };

    crate::generic::batch_hash::<WIDTH, CHUNK_SIZE, _, _>(&bab_instantiation, bytes, &mut out.0);
}

/// Computes the keyed WILLIAM3 digest of the given input bytes for a given `key`, and writes the digest into `out`.
///
/// This is the simplemost hashing API; it requires the full string to be available at once. See the [`Hasher`](crate::Hasher) API for incremental hashing.
pub fn batch_hash_keyed(bytes: &[u8], key: [u32; 8], out: &mut William3Digest) {
    let (hash_chunk_context, hash_inner_context) = (
        HashChunkContext::new_keyed(key),
        HashInnerContext::new_keyed(key),
    );

    let bab_instantiation = BabInstantiation {
        hash_chunk,
        hash_inner,
        hash_chunk_context,
        hash_inner_context,
    };

    crate::generic::batch_hash::<WIDTH, CHUNK_SIZE, _, _>(&bab_instantiation, bytes, &mut out.0);
}