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
45
46
47
48
49
50
51
52
//! Fast non-cryptographic hash traits (**NOT CRYPTO**).
use Debug;
/// A fast non-cryptographic hash.
///
/// These hashes are suitable for hash tables, sharding, fingerprints, and other
/// non-adversarial settings. They are **not** suitable for signatures, MACs,
/// password hashing, or untrusted inputs where collision attacks matter.
///
/// This trait is intentionally one-shot. Streaming APIs for fast hashes often
/// require algorithm-specific buffering and are exposed as concrete types.
///
/// # Examples
///
/// ```rust
/// # use rscrypto::traits::FastHash;
/// # struct MyHash;
/// # impl FastHash for MyHash {
/// # const OUTPUT_SIZE: usize = 8;
/// # type Output = u64;
/// # type Seed = u64;
/// # fn hash_with_seed(seed: u64, data: &[u8]) -> u64 {
/// # data.iter().fold(seed, |acc, &b| acc.wrapping_add(u64::from(b)))
/// # }
/// # }
///
/// let hash = MyHash::hash(b"hello world");
/// let seeded = MyHash::hash_with_seed(42, b"hello world");
/// assert_ne!(hash, seeded);
/// ```