java.lang.Object
app.keve.ktlsh.TLSHUtil
public final class TLSHUtil extends Object
Utility class to perform basic operations on TLSH hashes.
- Author:
- keve
-
Method Summary
Modifier and Type Method Description static String
bytesToHEX(byte[] bytes)
Convert a byte buffer to upper case hex character string.static String
encoded(byte[] hash)
Encode the buffer representation of the TLSH hash.static String
encodedT1(byte[] hash)
Encode the buffer representation of the TLSH hash with version prefix.static byte[]
hexToBytes(CharSequence hex)
Convert a sequence of hex characters to a buffer of bytes.static String
providerNameK()
Obtain the name of the K provider.static void
registerProvider()
Dynamically register the K provider.static int
score(byte[] hash1, byte[] hash2, boolean lenDiff)
Score two TLSH hashes in buffer representation.
-
Method Details
-
providerNameK
Obtain the name of the K provider.- Returns:
- the name of the K provider.
-
registerProvider
public static void registerProvider()Dynamically register the K provider. -
hexToBytes
Convert a sequence of hex characters to a buffer of bytes.- Parameters:
hex
- the hex string- Returns:
- the byte buffer
-
bytesToHEX
Convert a byte buffer to upper case hex character string.- Parameters:
bytes
- the buffer- Returns:
- the hex string
-
encoded
Encode the buffer representation of the TLSH hash.- Parameters:
hash
- the TLSH hash in buffer representation.- Returns:
- the TLSH hash in hexadecimal string representation.
-
encodedT1
Encode the buffer representation of the TLSH hash with version prefix.- Parameters:
hash
- the TLSH hash in buffer representation.- Returns:
- the TLSH hash in hexadecimal string representation with version prefix.
-
score
public static int score(byte[] hash1, byte[] hash2, boolean lenDiff)Score two TLSH hashes in buffer representation.- Parameters:
hash1
- the TLSH hash in buffer representation.hash2
- the TLSH hash in buffer representation.lenDiff
- true, if the length difference should be scored.- Returns:
- the score value.
-