StupidBeauty
Read times:4726Posted 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

 
Recent comments
2017年4月~2019年4月垃圾短信排行榜Posted at:Thu Sep 26 04:51:48 2024
Qt5.7文档翻译:QWebEngineCookieStore类,QWebEngineCookieStore ClassPosted at:Fri Aug 11 06:50:35 2023盲盒kill -9 18289 Grebe.20230517.211749.552.mp4