Giter VIP home page Giter VIP logo

tlsh2's Introduction

TLSH2

Build status Crates.io Documentation

Rust port of the TLSH library. The code is kept close to the original C++ version, to limit bugs and help maintainability

This crate is no_std and different configurations of bucket numbers and checksum length are handled as generics, making every configuration properly optimized.

// The default builder uses 128 buckets and a 1-byte checksum.
// Other builders are also available.
let mut builder = tlsh2::TlshDefaultBuilder::new();
builder.update(b"Sed ut perspiciatis unde omnis iste natus");
builder.update(b"error sit voluptatem accusantium");
let tlsh = builder.build()
    .ok_or_else(|| "could not generate TLSH from payload")?;

// Alternatively, a TLSH object can be generated directly from
// a byte slice.
let tlsh2 = tlsh2::TlshDefaultBuilder::build_from(
    b"odit aut fugit, sed quia consequuntur magni dolores"
).ok_or_else(|| "could not generate TLSH from second payload")?;

// Then, the TLSH object can be used to generated a hash or compute
// distances
assert_eq!(
    tlsh.hash(),
    b"T184A022B383C2A2A20ACB0830880CF0202CCAC080033A023800338\
      A30B0880AA8E0BE38".as_slice(),
);
// The `diff` feature is required for this computation.
assert_eq!(tlsh.diff(&tlsh2, true), 209);

Those configurations are available:

  • 128 buckets and 1-byte checksum (default).
  • 128 buckets and 3-byte checksum.
  • 256 buckets and 1-byte checksum.
  • 256 buckets and 3-byte checksum.
  • 48 buckets and 1-byte checksum.

The threaded and private options that exists in the original TLSH version are not yet implemented.

tlsh2's People

Contributors

vthib avatar dkrisman 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.