[][src]Crate blake3

The official Rust implementation of the BLAKE3 cryptographic hash function.

Examples

// Hash an input all at once.
let hash1 = blake3::hash(b"foobarbaz");

// Hash an input incrementally.
let mut hasher = blake3::Hasher::new();
hasher.update(b"foo");
hasher.update(b"bar");
hasher.update(b"baz");
let hash2 = hasher.finalize();
assert_eq!(hash1, hash2);

// Extended output. OutputReader also implements Read and Seek.
let mut output = [0; 1000];
let mut output_reader = hasher.finalize_xof();
output_reader.fill(&mut output);
assert_eq!(&output[..32], hash1.as_bytes());

Cargo Features

The rayon feature provides Rayon-based multi-threading, in particular the join::RayonJoin type for use with Hasher::update_with_join. It is disabled by default, but enabled for docs.rs.

The pure feature disables all FFI to C and assembly implementations, leaving only the Rust intrinsics implementations for SSE4.1 and AVX2. This removes the dependency on a C compiler/assembler. Library crates should generally avoid this feature, so that each binary crate is free make its own decision about build dependencies.

Modules

join

The multi-threading abstractions used by Hasher::update_with_join.

traits

Implementations of commonly used traits like digest::Digest and crypto_mac::Mac.

Structs

Hash

An output of the default size, 32 bytes, which provides constant-time equality checking.

Hasher

An incremental hash state that can accept any number of writes.

OutputReader

An incremental reader for extended output, returned by Hasher::finalize_xof.

Constants

KEY_LEN

The number of bytes in a key, 32.

OUT_LEN

The number of bytes in a Hash, 32.

Functions

derive_key

The key derivation function.

hash

The default hash function.

keyed_hash

The keyed hash function.