Crate bab_rs

Crate bab_rs 

Source
Expand description

An implementation of the Bab family of hash functions.

The crate root exposes the WILLIAM3 instantiation of Bab, which is a concrete hash function you can use immediately. The generic module provides parmaterisable implementations of Bab, which you can use to define your own hash functions.

use bab_rs::{batch_hash, William3Hasher, William3Digest, WIDTH, Hasher, HasherWrite};
let mut hasher = William3Hasher::new();
hasher.write(&[0, 1, 2]);
hasher.write(&[3, 4]);
let incrementally_computed_hash = hasher.finish();

let mut batch_digest = William3Digest::default();
batch_hash(&[0, 1, 2, 3, 4], &mut batch_digest);

assert_eq!(
    hasher.finish(),
    batch_digest,
);

§Features

The william3 feature controls whether the implementations of WILLIAM3 are included. This feature is enabled by default.

The dev feature adds implementations of the Arbitrary trait to various types. This feature is not enabled by default.

Modules§

generic
A generic implementation of the Bab family of hash functions.

Structs§

William3Digest
William3Hasher
A stateful hasher for incrementally computing WILLIAM3 digests.

Constants§

WIDTH
The number of bytes in a WILLIAM3 digest.

Traits§

Hasher
A trait for hashing an arbitrary stream of bytes. The write methods are defined in the HasherWrite trait.
HasherWrite
A trait for writing data to a hasher.

Functions§

batch_hash
Computes the WILLIAM3 digest of the given input bytes, and writes it into out.
batch_hash_keyed
Computes the keyed WILLIAM3 digest of the given input bytes for a given key, and writes the digest into out.