๐ Welcome to rbindiff โ A Binary File Comparison Tool! ๐
rbindiff compares binary files byte by byte, highlights differences, and calculates similarity ratios.
rbindiff stands for "Ruby Binary Diff". It's a command-line tool written in Ruby that:
โขCompares two binary files byte-by-byte.
โขOutputs a human-readable summary of:
โขRanges where the files are identical
โขRanges where they differ, with short hex representations
โขExtra content at the end if one file is longer than the other
โขCalculates similarity percentage based on matching bytes.
gem install rbindiff
Once installed, you'll have access to the rbindiff executable in your terminal.
rbindiff <file1> <file2>
rbindiff image1.png image2.png
Comparing: image1.png vs image2.png
[Identical] Bytes 0x0000 to 0x00FF (256 bytes)
[Different] Bytes 0x0100 to 0x010F (16 bytes)
File1: 48 65 6C 6C 6F 20 77 6F ... 6E 67 20 77 6F 72 6C 64
File2: 48 65 6C 6C 6F 20 77 6F ... 6E 67 20 57 4F 52 4C 44
[Identical] Bytes 0x0110 to 0x01FF (240 bytes)
[Extra] File2 has 32 extra bytes from 0x0200 to 0x021F
Similarity: 92.5% (same bytes) / 89.1% (relative to total lengths)
โ
Byte-level comparison
โ
Human-readable output
โ
Hex dump of differing regions (with ellipsis)
โ
Similarity percentages
โ
Supports files of different lengths
โ
Terminal-safe formatting
rbindiff/
โโโ bin/
โ โโโ rbindiff # Executable script
โโโ lib/
โ โโโ rbindiff.rb # Main logic
โโโ rbindiff.gemspec
โโโ Gemfile
โโโ README.md # You're reading this!
โโโ .gitignore
The core algorithm works like this:
1.Open both files as binary streams.
2.Read them into byte arrays.
3.Compare byte-by-byte up to the minimum length.
4.Track ranges of identical or differing bytes.
5.If one file is longer, record the extra part.
6.Print the result with range info, diffs, and similarity ratio.
There are two values:
โข% Matched: (Same bytes) / min(file1.size, file2.size)
โข% Relative: (Same bytes) / max(file1.size, file2.size)
This gives an idea of how similar the common parts are, and how much of the larger file matches.
rbindiff helps developers debug binaries, reverse-engineer files, and understand low-level data formats.
HxLauncher: Launch Android applications by voice commands