Compare Binary Streams
Compare two binary streams byte-by-byte. Upload files, paste hex or text. View diff summary, hex dump with highlights, and visual diff heatmap.
About
Binary comparison errors propagate silently. A single flipped bit in firmware, a corrupted byte in a cryptographic key, or a transmission error in a serialized protocol buffer can cause catastrophic downstream failures without any human-readable symptom. This tool performs a strict byte-level comparison of two binary streams, reporting every offset where stream A diverges from stream B. It computes the Hamming distance dH, percentage similarity, and renders a visual heatmap so spatial patterns in corruption become immediately obvious. Input accepts raw files (up to 50 MB), hex-encoded strings, or plain UTF-8 text encoded to bytes. The tool approximates diff analysis assuming both streams share a common alignment at offset 0. It does not perform sequence alignment or fuzzy matching. For streams of unequal length, trailing bytes in the longer stream are flagged as overflow differences.
Formulas
The primary metric is the Hamming distance computed over the overlapping region of both streams:
where δ is the Kronecker indicator returning 1 on mismatch. The total difference count includes overflow bytes:
Similarity as a percentage over the maximum stream length:
where A[i] is the byte at offset i in stream A, nA is byte length of stream A, nB is byte length of stream B, D is total differences including overflow, and S is similarity percentage.
Reference Data
| Metric | Symbol | Description | Range |
|---|---|---|---|
| Hamming Distance | dH | Count of byte positions where streams differ | 0 - min(nA, nB) |
| Similarity | S | Percentage of matching bytes over max length | 0 - 100 % |
| First Diff Offset | f | Byte offset of the earliest mismatch | 0 - n−1 |
| Last Diff Offset | l | Byte offset of the latest mismatch | 0 - n−1 |
| Stream A Size | nA | Total bytes in stream A | 0 - 52428800 B |
| Stream B Size | nB | Total bytes in stream B | 0 - 52428800 B |
| Overflow Bytes | Δn | Absolute size difference between streams | 0 - 52428800 B |
| Diff Density | ρ | Ratio of differing bytes to compared range | 0.0 - 1.0 |
| Match Count | m | Number of identical byte positions | 0 - n |
| Compared Length | min(nA, nB) | Number of byte positions actually compared | 0 - 52428800 |
| Hex Byte | - | Two-character representation, base-16 | 00 - FF |
| ASCII Printable Range | - | Characters rendered in hex dump sidebar | 0x20 - 0x7E |