File: README.md

package info (click to toggle)
tlsh 4.12.1%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 19,952 kB
  • sloc: cpp: 9,128; python: 1,603; java: 1,214; sh: 703; javascript: 467; ansic: 54; makefile: 27; sed: 9
file content (41 lines) | stat: -rw-r--r-- 1,127 bytes parent folder | download
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
# Java port of TLSH

This folder contains a Java port of the Trend Micro Locality Sensitive Hash algorithm.

This port has no additional JAR dependencies and only requires the JRE.

## Use with gradle

Pre-built TLSH libraries will be available on Maven Central soon but for now they
must be built from source.

```bash
git clone https://github.com/trendmicro/tlsh.git
cd tlsh/java
./gradlew clean build
```

This will produce JAR files in `build/libs` that can be included in other projects.

## Example
```java
import com.trendmicro.tlsh.Tlsh;
import com.trendmicro.tlsh.TlshCreator;


TlshCreator tlshCreator = new TlshCreator();
byte[] buf = new byte[1024];
InputStream is = ...; // however you get your input
int bytesRead = is.read(buf, 0, buf.length);
while (bytesRead >= 0) {
  tlshCreator.update(buf, 0, bytesRead);
  bytesRead = is.read(buf, 0, buf.length);
}
is.close();
Tlsh hash = tlshCreator.getHash();
System.out.println("Hash is " + hash.getEncoded());

Tlsh otherHash = ...; // compute another hash
int diff = hash.totalDiff(otherHash, true);
System.out.println("TLSH difference between data is " + diff);
```