Git Product home page Git Product logo

ssdeep-rs's Introduction

Rust Wrapper for ssdeep

docs.rs crates.io

A Rust wrapper for ssdeep by Jesse Kornblum, which is a C library for computing context triggered piecewise hashes (CTPH). Also called fuzzy hashes, CTPH can match inputs that have homologies. Such inputs have sequences of identical bytes in the same order, although bytes in between these sequences may be different in both content and length. In contrast to standard hashing algorithms, CTPH can be used to identify files that are highly similar but not identical. See my blog post for more details.

Usage

To compute the fuzzy hash of a given buffer, use the hash() function:

extern crate ssdeep;

let h = ssdeep::hash(b"Hello there!").unwrap();
assert_eq!(h, "3:aNRn:aNRn");

If you want to obtain the fuzzy hash of a file, you can use hash_from_file():

let h = ssdeep::hash_from_file("path/to/file").unwrap();

To compare two fuzzy hashes, use compare(), which returns an integer between 0 (no match) and 100:

let h1 = b"3:AXGBicFlgVNhBGcL6wCrFQEv:AXGHsNhxLsr2C";
let h2 = b"3:AXGBicFlIHBGcL6wCrFQEv:AXGH6xLsr2Cx";
let score = ssdeep::compare(h1, h2).unwrap();
assert_eq!(score, 22);

Each of these functions returns an Option, where None is returned when the underlying C function fails.

Installation

Add the following lines into your Cargo.toml file:

[dependencies]
ssdeep = "0.1.0"

Then, when you run cargo build, it will automatically get the wrapper's source code from crates.io, compile the underlying C library, and build the wrapper. The C library is statically linked into the wrapper.

The build process is known to work under Linux with GCC. If you have a different operating system or compiler and the build fails, feel free to submit a pull request or open an issue.

Documentation

An automatically generated API documentation is available here:

License

The wrapper's code is licensed under the terms of GPLv3.

This wrapper includes the unchanged source distribution of ssdeep version 2.13, which is compiled and statically linked into the wrapper during build. It is licensed under GPLv2.

ssdeep-rs's People

Contributors

s3rvac avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.