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
// SPDX-License-Identifier: Apache-2.0 OR MIT
// SPDX-FileCopyrightText: Copyright (C) 2024 Tsukasa OI <floss_ssdeep@irq.a4lg.com>.
//! The easy wrapper for generator functionalities.
use crateGeneratorError;
use crateGenerator;
use crateConstrainedFuzzyHashType;
use crate::;
/// Generates a fuzzy hash from a given buffer
/// (with specified output type).
///
/// # Example
///
/// ```
/// type CustomTlsh = tlsh::hashes::Short;
///
/// // Make a fuzzy hash from the buffer.
/// let hash = tlsh::hash_buf_for::<CustomTlsh>(b"Hello, World!").unwrap();
///
/// // Compare with known result.
/// // Note: short fuzzy hashes accept very short inputs.
/// assert_eq!(hash.to_string(), "T1E16004017D3551777571D55C005CC5");
/// ```
/// Generates a fuzzy hash from a given buffer.
///
/// # Example
///
/// ```
/// // Make a fuzzy hash from the buffer.
/// let hash = tlsh::hash_buf(
/// b"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do \
/// eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad \
/// minim veniam, quis nostrud exercitation ullamco laboris nisi ut \
/// aliquip ex ea commodo consequat. Duis aute irure dolor in \
/// reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla \
/// pariatur. Excepteur sint occaecat cupidatat non proident, sunt in \
/// culpa qui officia deserunt mollit anim id est laborum.",
/// )
/// .unwrap();
///
/// // Compare with known result.
/// assert_eq!(
/// hash.to_string(),
/// "T1DCF0DC36520C1B007FD32079B226559FD998A0200725E75AFCEAC99F5881184A4B1AA2"
/// );
/// ```