TLSH2
Rust port of the TLSH library.
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 = new;
builder.update;
builder.update;
let tlsh = builder.build
.ok_or_else?;
// Alternatively, a TLSH object can be generated directly from
// a byte slice.
let tlsh2 = build_from.ok_or_else?;
// Then, the TLSH object can be used to generated a hash or compute
// distances
assert_eq!;
// The `diff` feature is required for this computation.
assert_eq!;
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.
Features
- The
difffeature adds the ability to compute the difference between two hashes, but adds a 64kB lookup table - The
fastfeature speeds up TLSH generation but adds an additional 64kB lookup table.
The threaded and private options that exists in the original TLSH version
are not yet implemented.
Benchmarks
Some benchmarks are available here. Thanks to @Havunen for creating them.
Contributions
Thanks to @barrbrain for contributing several performance improvements.