Shannon
A Rust CLI utility that calculates and visualizes block-wise Shannon entropy of files. Shannon aims to be command line based replacement for binwalk -E.
Shannon is available on crates.io and on github.
What is Shannon Entropy?
Shannon entropy measures the randomness or information density in data. Values range from 0 to 8 bits per byte:
- 0: Completely uniform (e.g., a file of all zeros)
- ~4-5: Typical text or code
- ~7-8: High randomness (encrypted or compressed data)
Use Cases
- Malware analysis: Identify packed or encrypted sections in executables
- File forensics: Detect hidden or embedded data within files
- Compression analysis: Visualize which parts of a file are already compressed
- Binary reverse engineering: Understand file structure and locate data regions
Screenshot

Installation
Via crates.io
Local build
The binary will be at target/release/shannon.
Usage
Options
| Option | Short | Default | Description |
|---|---|---|---|
--block-size |
-b |
1024 | Block size in bytes for entropy calculation |
--width |
180 | Chart width in characters | |
--height |
100 | Chart height in characters | |
--y-max |
-y |
auto | Maximum Y-axis value (defaults to max entropy found) |
--no-plot |
-n |
false | If set then no graph is plotted |
--quiet |
-q |
false | If set then no summary is printed |
--high |
-H |
0.95 | High threshold for rising edge detection |
--low |
-L |
0.85 | Low threshold for falling edge detection |
--no-table |
false | If set then no edge table is printed |
Examples
Analyze a binary with default settings:
Use smaller blocks for finer granularity:
Compact output for smaller terminals:
Output
A line summarizing the review is outputted.
The tool renders a bar chart in the terminal where:
- X-axis: Block index (position in file)
- Y-axis: Entropy value (0-8 bits per byte)
High entropy regions appear as tall bars, making it easy to spot encrypted or compressed sections at a glance.
A table of rising and falling edges in the entropy.
Library Usage
The crate also exposes a library for use in your own projects:
use ;
// Calculate entropy of data (returns bits per byte, 0.0-8.0)
let data = b"Hello, world!";
let e: f64 = entropy;
// Calculate total entropy (bits per byte * length)
let total: f64 = total_entropy;
// Detect rising/falling entropy edges in a sequence
let values: = vec!;
let edges = detect_edges; // high/low thresholds
for edge in edges
Todo
- Implement dynamic
BLOCK_SIZElike binwalk (so identical output is produced without manually matching BLOCK_SIZE). - Enable input via stdin
License
MIT