Crate blake3[−][src]
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()); // Print a hash as hex. println!("{}", hash1.to_hex());
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 neon feature enables ARM NEON support. Currently there is no runtime
CPU feature detection for NEON, so you must only enable this feature for
targets that are known to have NEON support. In particular, some ARMv7
targets support NEON, and some don’t.
The std feature (enabled by default) is required for implementations of
the Write and Seek traits, and also for runtime CPU feature
detection. If this feature is disabled, the only way to use the SIMD
implementations in this crate is to enable the corresponding instruction
sets statically for the entire build, with e.g. RUSTFLAGS="-C target-cpu=native". The resulting binary will not be portable to other
machines.
Modules
| join | The multi-threading abstractions used by |
| traits | Implementations of commonly used traits like
|
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
|
Constants
| KEY_LEN | The number of bytes in a key, 32. |
| OUT_LEN | The number of bytes in a |
Functions
| derive_key | The key derivation function. |
| hash | The default hash function. |
| keyed_hash | The keyed hash function. |