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
//! Shannon entropy over byte slices.
//!
//! Used to classify slack regions: entropy ≈ 0.0 → all-zero/wiped;
//! entropy < 1.0 → low variety (e.g., repeated pattern); entropy > 6.0
//! → likely compressed, encrypted, or random data.
/// Entropy (bits/byte) above which a slack region is treated as likely
/// data-bearing — compressed, encrypted, or random rather than padding.
/// This is the single threshold the severity model consults for slack.
pub const HIGH_ENTROPY_THRESHOLD: f64 = 6.0;
/// Compute the Shannon entropy (bits per byte, range 0.0–8.0) of `data`.
///
/// Returns `0.0` for an empty slice.
/// Returns `true` if `data` is entirely one repeated byte value.