1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
use Lazy;
use ;
/// A simple counter which is initialized at 0.
static GLOBAL_ID_COUNTER: = new;
// TODO: If converting a full SHA-1 hash to a compact u64 fingerprint, use a mixing
// strategy like this FNV-1a fold.
//
// fn sha1_to_u64_fnv_fold(digest: &[u8; 20]) -> u64 {
// const FNV_OFFSET: u64 = 0xcbf29ce484222325;
// const FNV_PRIME: u64 = 0x100000001b3;
//
// let mut hash = FNV_OFFSET;
// for &b in digest {
// hash ^= b as u64;
// hash = hash.wrapping_mul(FNV_PRIME);
// }
// hash
// }
//
// This compresses all 160 bits of SHA-1 into a single u64 using a fast, deterministic
// non-cryptographic hash (FNV-1a). It preserves more entropy than simple truncation,
// is collision-resistant for non-adversarial use, and works well for local indexing,
// deduplication hints, or stable identifiers.
//
// ⚠️ Not cryptographically secure — do not use for authentication, digital signatures,
// or any use case requiring preimage or collision resistance.
// fn sha1_to_u64_fnv_fold(digest: &[u8; 20]) -> u64 {
// const FNV_OFFSET: u64 = 0xcbf29ce484222325;
// const FNV_PRIME: u64 = 0x100000001b3;
// let mut hash = FNV_OFFSET;
// for &b in digest {
// hash ^= b as u64;
// hash = hash.wrapping_mul(FNV_PRIME);
// }
// hash
// }