//! FNV-1a hashing for state checksums. //! //! The hash only has to reveal accidental divergence between peers. It is //! not meant to resist tampering. const FNV_OFFSET_BASIS: u64 = 0xcbf2_9ce4_8422_2325; const FNV_PRIME: u64 = 0x0000_0100_0000_01b3; /// Returns the 64-bit FNV-1a hash of `bytes`. pub fn fnv1a64(bytes: &[u8]) -> u64 { let mut hash = FNV_OFFSET_BASIS; for &byte in bytes { hash ^= u64::from(byte); hash = hash.wrapping_mul(FNV_PRIME); } hash }