Shared utility functions. FNV-1a 64-bit hash of a byte slice. Deterministic, non-cryptographic hash suitable for in-process IDs (R-tree entries, HLL sketches, deduplication keys). NOT suitable for security-sensitive hashing — use SHA-256 for that.
(bytes: &[u8])
| 8 | /// (R-tree entries, HLL sketches, deduplication keys). NOT suitable |
| 9 | /// for security-sensitive hashing — use SHA-256 for that. |
| 10 | pub fn fnv1a_hash(bytes: &[u8]) -> u64 { |
| 11 | let mut hash: u64 = 0xcbf29ce484222325; // FNV-1a offset basis |
| 12 | for &b in bytes { |
| 13 | hash ^= b as u64; |
| 14 | hash = hash.wrapping_mul(0x100000001b3); // FNV prime |
| 15 | } |
| 16 | hash |
| 17 | } |
| 18 | |
| 19 | #[cfg(test)] |
| 20 | mod tests { |
no outgoing calls
no test coverage detected