1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
//! TLSH
//!
//! A Rust implementation of the TLSH algorithm.
//! 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.
//! #[cfg(feature = "diff")]
//! assert_eq!(tlsh.diff(&tlsh2, true), 209);
//! # Ok::<(), Box<dyn std::error::Error>>(())
//! ```
const BUCKETS: usize = 256;
pub use crate;
/// Builder with 256 buckets and a 1 byte checksum.
pub type TlshBuilder256_1 = ;
/// TLSH with 256 buckets and a 1 byte checksum.
pub type Tlsh256_1 = ;
/// Builder with 128 buckets and a 1 byte checksum.
pub type TlshBuilder128_1 = ;
/// TLSH with 128 buckets and a 1 byte checksum.
pub type Tlsh128_1 = ;
/// Builder with 48 buckets and a 1 byte checksum.
pub type TlshBuilder48_1 = ;
/// TLSh with 48 buckets and a 1 byte checksum.
pub type Tlsh48_1 = ;
/// Builder with 256 buckets and a 3 bytes checksum.
pub type TlshBuilder256_3 = ;
/// TLSH with 256 buckets and a 3 bytes checksum.
pub type Tlsh256_3 = ;
/// Builder with 128 buckets and a 3 bytes checksum.
pub type TlshBuilder128_3 = ;
/// TLSH with 128 buckets and a 3 bytes checksum.
pub type Tlsh128_3 = ;
/// Default builder, using 128 buckets and a 1 byte checksum.
pub type TlshDefaultBuilder = TlshBuilder128_1;
/// Default TLSH, using 128 buckets and a 1 byte checksum.
pub type TlshDefault = Tlsh128_1;