Expand description
§Entropy
A Rust library for calculating Shannon entropy of byte sequences.
§Overview
Shannon entropy measures the average amount of information (in bits) contained in a message. It’s commonly used in:
- Cryptography (measuring randomness)
- Data compression (estimating compressibility)
- Malware analysis (detecting packed/encrypted content)
- Password strength estimation
§Quick Start
use entropy::shannon_entropy;
// Calculate Shannon entropy (bits)
let h = shannon_entropy("hello, world");
assert_eq!(h, 3.0220551);§Interpreting Results
- Shannon entropy ranges from 0 to 8 bits for byte data
- 0 = completely uniform (e.g., “aaaa”)
- 8 = maximum entropy (all 256 byte values equally distributed)
Functions§
- metric_
entropy - shannon_
entropy - Calculates the Shannon entropy of a byte sequence.