MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / fnv1a_hash

Function fnv1a_hash

nodedb/src/util.rs:10–17  ·  view source on GitHub ↗

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])

Source from the content-addressed store, hash-verified

8/// (R-tree entries, HLL sketches, deduplication keys). NOT suitable
9/// for security-sensitive hashing — use SHA-256 for that.
10pub 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)]
20mod tests {

Callers 11

predicate_classFunction · 0.50
stable_collection_oidFunction · 0.50
stable_index_oidFunction · 0.50
build_applyFunction · 0.50
insert_spatial_docFunction · 0.50
apply_point_putMethod · 0.50
execute_point_deleteMethod · 0.50
observeMethod · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected