pub fn hash(input: &[u8]) -> HashExpand description
The hash of input, on the calling thread.
let hash = blake3_servil_core::convenience::hash(b"foo");
let mut hasher = blake3_servil_core::convenience::Hasher::new(blake3_servil_core::Mode::Plain, None);
hasher.update(b"foo");
let hash = hasher.finalize();For a keyed hash or key derivation, see hash_with; for output sizes
other than 32 bytes, hash_xof. For speed (other cores, batches,
streams, a message fed in pieces), the throughput
calls.
Speed, nonstop on an Apple M4 Max: about 55 ns for 64 bytes, 0.8 µs for 1 KiB, 4 GB/s at 16 KiB, and 6 GB/s from 1 MiB. A call after a pause or after other work takes longer (its code and data have left the CPU’s caches): 64 bytes then take about 0.5 to 0.6 µs. On Apple M4 and later, threads that hash inputs of 16 KiB or more at the same moment share one accelerator: one runs at full speed and the others at about two thirds of it.
Call initialize once, before the first hash in
a process: it runs the self-test (see the crate’s documentation), under
0.2 ms. A hash before it panics.