Skip to main content

fnv1a_hash

Function fnv1a_hash 

Source
pub fn fnv1a_hash(data: &[u8]) -> u64
Expand description

FNV-1a 64-bit hash of a byte slice.

A fast, non-cryptographic hash function suitable for hash-map keys and general fingerprinting. Produces well-distributed hashes for short strings.

The FNV-1a variant XORs each byte into the hash before multiplying, providing better avalanche characteristics than FNV-1.

ยงExamples

use numrs2::new_modules::string_algorithms::fnv1a_hash;

let h = fnv1a_hash(b"hello");
assert_ne!(h, 0);
// FNV-1a of empty data is the offset basis.
assert_eq!(fnv1a_hash(b""), 14_695_981_039_346_656_037u64);