Compare binary files using alignment algorithms

Overview

biodiff

Compare binary files using alignment algorithms.

What is this

This is a tool for binary diffing.

The tool is able to show two binary files side by side so that similar places will be at the same position on both sides and bytes missing from one side are padded. It uses bio-informatics algorithms from the rust-bio library (typically used for DNA sequence alignment) for that.

Usage

Execute biodiff file_a file_b in a terminal and you should be dropped into a hex view showing two files side by side. Initially, the files will not be aligned and displayed without gaps on each side. By moving the cursor and views to a place where the left side and right side are similar and pressing F3, they can be aligned. This is done block by block in standard configuration, which means that bytes near the cursor are aligned first and the other displayed later.

It is also possible to do global and local alignment (of the whole files at once) by changing the settings using F4 (be sure to consult the help on the parameters). Generally, since it takes quadratic time and space, the global/local alignment will not work well for files bigger than 64kB. There is also a "banded" algorithm which is faster, but slightly less accurate.

It woul

Installation

There should be downloadable binary files for some environments under the releases page. Alternatively, you can also install this using cargo by doing cargo install biodiff.

You can also execute directly using code from this repository by executing cargo run --release -- file_a file_b.

License

This project is licensed under MIT.

Comments
  • Mode to print single bytes as ASCII if possible

    Mode to print single bytes as ASCII if possible

    Thanks for publishing your work. What do you think about having a mode (not default but available in F4) to print those bytes which have a printable ASCII character assigned as ASCII instead of the hex number? E.g.,

    ff \n  a
    

    instead of

    ff 0a 61
    

    where the leading space for a makes it clear that it is ASCII and not hex, and common escaped characters could also be shown as \n, \r, or \t etc.

    opened by pothos 8
  • Build fails

    Build fails

    > cargo install biodiff
    error[E0658]: or-patterns syntax is experimental
       --> /home/c0d3/.cargo/registry/src/github.com-1ecc6299db9ec823/biodiff-0.2.1/src/drawer.rs:131:25
        |
    131 |     if matches!(a, Some(b'!'..=b'~' | b' ' | b'\n' | b'\t' | b'\r')) {
        |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |
        = note: see issue #54883 <https://github.com/rust-lang/rust/issues/54883> for more information
    
    error[E0277]: `[(&str, usize); 7]` is not an iterator
       --> /home/c0d3/.cargo/registry/src/github.com-1ecc6299db9ec823/biodiff-0.2.1/src/dialog.rs:391:19
        |
    391 |           .with_all([
        |  ___________________^
    392 | |             ("Hex", 0usize),
    393 | |             ("Binary", 1),
    394 | |             ("Decimal", 2),
    ...   |
    398 | |             ("Roman", 6),
    399 | |         ])
        | |_________^ expected an implementor of trait `IntoIterator`
        |
        = note: the trait bound `[(&str, usize); 7]: IntoIterator` is not satisfied
        = note: required because of the requirements on the impl of `IntoIterator` for `[(&str, usize); 7]`
    help: consider borrowing here
        |
    391 |         .with_all(&[
    392 |             ("Hex", 0usize),
    393 |             ("Binary", 1),
    394 |             ("Decimal", 2),
    395 |             ("Octal", 3),
    396 |             ("Hex/Ascii Mixed", 4),
      ...
    
    error[E0277]: `[(&str, {integer}); 2]` is not an iterator
       --> /home/c0d3/.cargo/registry/src/github.com-1ecc6299db9ec823/biodiff-0.2.1/src/dialog.rs:451:35
        |
    451 |                         .with_all([("Algorithm", 0), ("Display Style", 1)])
        |                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |                                   |
        |                                   expected an implementor of trait `IntoIterator`
        |                                   help: consider borrowing here: `&[("Algorithm", 0), ("Display Style", 1)]`
        |
        = note: the trait bound `[(&str, {integer}); 2]: IntoIterator` is not satisfied
        = note: required because of the requirements on the impl of `IntoIterator` for `[(&str, {integer}); 2]`
    
    error[E0658]: use of unstable library feature 'assoc_char_funcs': recently added
      --> /home/c0d3/.cargo/registry/src/github.com-1ecc6299db9ec823/biodiff-0.2.1/src/drawer.rs:63:32
       |
    63 |             let braille_char = char::from_u32(0x2800u32 + reordered_byte as u32)
       |                                ^^^^^^^^^^^^^^
       |
       = note: see issue #71763 <https://github.com/rust-lang/rust/issues/71763> for more information
    
    error[E0658]: use of unstable library feature 'assoc_char_funcs': recently added
      --> /home/c0d3/.cargo/registry/src/github.com-1ecc6299db9ec823/biodiff-0.2.1/src/drawer.rs:73:49
       |
    73 |         Some(c @ b'!'..=b'~') => format!("{} ", char::from_u32(c as u32 + 0xFF00 - 0x20).unwrap()),
       |                                                 ^^^^^^^^^^^^^^
       |
       = note: see issue #71763 <https://github.com/rust-lang/rust/issues/71763> for more information
    
    error: aborting due to 5 previous errors
    
    Some errors have detailed explanations: E0277, E0658.
    For more information about an error, try `rustc --explain E0277`.
    error: failed to compile `biodiff v0.2.1`, intermediate artifacts can be found at `/tmp/cargo-install9qq2oD`
    
    Caused by:
      could not compile `biodiff`
    
    To learn more, run the command again with --verbose.
    
    bug 
    opened by c0d3z3r0 2
  • Add BIODIFF_CONFIG_DIR env variable to set custom settings directory

    Add BIODIFF_CONFIG_DIR env variable to set custom settings directory

    With this environment variable, biodiff can be used as a fully portable application from e.g. a USB flash drive, by creating a launcher script that sets the environment variable.

    Environment variable works better than a CLI option, because it automatically propagates through git-biodiff, git and other possible wrapper commands.

    opened by MatejKafka 1
  • Document alternate shortcuts for alignment

    Document alternate shortcuts for alignment

    On Mac specifically the F keys are often captured by the OS for specific purposes such as Mission Control. I currently have them bound to F1: change desktop left, F2: change desktop right, F3: show all windows. So to use biodiff right now I need to change my keyboard settings and then change them back after.

    It would be nice to have some alternate shortcuts that are less likely to be clobbered by OS settings. (Though it's not too hard to toggle the F3 shortcut in the OS settings).

    Thanks!

    biodiff is very cool and really helpful for finding the differences. Bioinformatics algorithms are perfect for this sort of thing.

    documentation 
    opened by JamesB797 1
  • Install git diff helper

    Install git diff helper

    When a git-biodiff executable is in the PATH, the user can run git biodiff instead of git diff.

    The git-biodiff executable needs to run git difftool --no-prompt --extcmd=biodiff and pass all parameters along.

    You can try this now by creating a git-biodiff bash script in your PATH:

    #!/bin/sh
    git difftool --no-prompt --extcmd=biodiff "$@"
    

    For cargo install to set this up it would need to be implemented in Rust instead of bash and multiple binaries be defined in the Cargo.toml via [[bin]]. Edit: Wasn't even necessary with the autobin feature which is default in edition 2018.

    opened by pothos 1
  • add git-biodiff helper binary

    add git-biodiff helper binary

    To use biodiff as diff tool in git, the user may either run git difftool --no-prompt --extcmd=biodiff ... or, if a git-biodiff executable exists in the PATH, the user may run git biodiff ... and the git-biodiff executable would run the first command. This handy shortcut mechanism is also provided by icdiff when installing it.

    Define an additional Rust binary to be installed with cargo install which is easier than requiring the user to copy some bash script like #!/bin/sh git difftool --no-prompt --extcmd=biodiff "$@" to their PATH.

    Fixes https://github.com/8051Enthusiast/biodiff/issues/2

    opened by pothos 0
Releases(v1.0.3)
Owner
null
A browser app that evolves vehicles using genetic algorithms, written in Rust and Bevy

Vehicle Evolver Deluxe This is a simulation that uses AI (to be specific: genetic algorithms) to try to build better and better vehicles. The vehicles

null 95 Dec 26, 2022
Fast, parallel, extensible and adaptable genetic algorithms framework written in Rust

oxigen Oxigen is a parallel genetic algorithm framework implemented in Rust. The name comes from the merge of OXIdación (Rust translated to Spanish) a

Martín Pozo 146 Dec 18, 2022
darwin-rs, evolutionary algorithms with rust

darwin-rs This library allows you to write evolutionary algorithms (EA) using the Rust programming language. Written by Willi Kappler, License: MIT -

Willi Kappler 95 Jan 1, 2023
Radiate is a parallel genetic programming engine capable of evolving solutions to many problems as well as training learning algorithms.

Radiate Coming from Evolutionary Radiation. Evolutionary radiation is a rapid increase in the number of species with a common ancestor, characterized

kalivas 109 Dec 18, 2022
A tool used to evaluate the output of retrieval algorithms. Written in Rust.

Rusteval A tool used to evaluate the output of retrieval algorithms. Written in Rust. Building Install Rust with curl -sSf https://static.rust-lang.or

Giorgos Sfikas 17 Mar 22, 2022
This crate implements fast route planning algorithms in Rust.

This crate implements fast route planning algorithms in Rust. Algorithms Currently implemented: Contraction Hierarchies: The implementat

Payas Rajan 4 Aug 15, 2021
Genetic Algorithms Library

genx genx provides modular building blocks to run simulations of optimization and search problems using Genetic Algorithms (GA). The vision for genx i

Lakshya Singh 29 Aug 9, 2022
DSP algorithms for embedded. Often integer math.

This crate contains some tuned DSP algorithms for general and especially embedded use.

QUARTIQ 12 Nov 3, 2022
ECFFT algorithms on the BN254 base field

ECFFT algorithms on the BN254 base field This crate implements structs and traits for the ECFFT algorithms from the paper Elliptic Curve Fast Fourier

null 36 Nov 28, 2022
A library that can be used as a building block for high-performant graph algorithms.

graph A library that can be used as a building block for high-performant graph algorithms. Graph provides implementations for directed and undirected

Martin Junghanns 222 Jan 1, 2023
"Algorithms for approximate string matching" in Rust, with Python bindings.

ukkonen Implementation of a bounded Levenshtein distance by Esko Ukkonen in "Algorithms for approximate string matching" in Rust, with Python bindings

Ethan Smith 1 Dec 1, 2021
Common data structures and algorithms for competitive programming in Rust

algorithm-rs algorithm-rs is common data structures and algorithms for competitive programming in Rust. Contents TBA How To Contribute Contributions a

Chris Ohk 16 Dec 21, 2022
zine/book about bitmap drawing algorithms and math with code examples in Rust

A Bitmapper's Companion - zine/book about bitmap drawing algorithms and math with code examples in Rust A small zine/book written in LaTeX. In progres

Manos Pitsidianakis 42 Nov 8, 2022
Algorithms implemented in Rust, explained.

Rusty Algorithms & Data Structures for Learners This repository presents Rust implementations of common algorithms and data structures, many of which

Tianyi Shi 327 Dec 19, 2022
This library provides implementations of many algorithms and data structures that are useful for bioinformatics.

This library provides implementations of many algorithms and data structures that are useful for bioinformatics. All provided implementations are rigorously tested via continuous integration.

Rust-Bio 1.2k Dec 26, 2022
Bandit Algorithms in Rust

Multi-armed bandit algorithms in Rust Cargo [dependencies] bandit = "0.12.3" Description and Scope This library currently only implements the annealin

Michael Bohn 30 Nov 24, 2022
A Rust implementation the HOTP and TOTP Algorithms

xotp A Rust implementation the HOTP and TOTP Algorithms. HOTP was implemented in accordance with RFC4226 TOTP was implemented in accordance with RFC62

Tejas Mehta 3 Jan 21, 2022
A small collection of procedural dungeon generation algorithms.

mapgen A small collection of procedural dungeon generation algorithms. Built with Rust & macroquad. WebAssembly build deployed here. Animated version

null 16 Aug 17, 2022
Stalin Binary Search, Rust implementation

Stalin Binary Search Idea is based on Stalin Sort It's alike binary search but any checking element which is not target one is eliminated. Complexity

null 7 Dec 12, 2022