StupidBeauty
Read times:4622Posted at:Sun Jun 22 02:14:37 2025 - no title specified

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

๐ŸŒŸ Welcome to rbindiff โ€“ A Binary File Comparison Tool! ๐ŸŒŸ

rbindiff compares binary files byte by byte, highlights differences, and calculates similarity ratios.

 

๐Ÿš€ What is rbindiff?

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. 

 

๐Ÿ”ง Installation

gem install rbindiff

Once installed, you'll have access to the rbindiff executable in your terminal.

 

๐Ÿ“ฆ Usage

rbindiff <file1> <file2>

Example:

rbindiff image1.png image2.png

 

โœจ Sample Output

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)

 

๐Ÿ› ๏ธ Features

โœ… Byte-level comparison
โœ… Human-readable output
โœ… Hex dump of differing regions (with ellipsis)
โœ… Similarity percentages
โœ… Supports files of different lengths
โœ… Terminal-safe formatting

 

๐Ÿ“ Project Structure

rbindiff/

โ”œโ”€โ”€ bin/

โ”‚   โ””โ”€โ”€ rbindiff        # Executable script

โ”œโ”€โ”€ lib/

โ”‚   โ””โ”€โ”€ rbindiff.rb     # Main logic

โ”œโ”€โ”€ rbindiff.gemspec

โ”œโ”€โ”€ Gemfile

โ”œโ”€โ”€ README.md           # You're reading this!

โ””โ”€โ”€ .gitignore

 

๐Ÿ“ How It Works

The core algorithm works like this:

  1. 1.Open both files as binary streams. 

  2. 2.Read them into byte arrays. 

  3. 3.Compare byte-by-byte up to the minimum length. 

  4. 4.Track ranges of identical or differing bytes. 

  5. 5.If one file is longer, record the extra part. 

  6. 6.Print the result with range info, diffs, and similarity ratio. 

 

๐Ÿงฎ Similarity Calculation

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.

 

๐Ÿ™Œ You've Got This!

rbindiff helps developers debug binaries, reverse-engineer files, and understand low-level data formats.

 

 
Grammy Museum at L.A. live
Your opinions
Your name:Email:Website url:Opinion content:
- no title specified

HxLauncher: Launch Android applications by voice commands