Class TLSHUtil

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 Details

    • providerNameK

      public static String 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

      public static byte[] hexToBytes​(CharSequence hex)
      Convert a sequence of hex characters to a buffer of bytes.
      Parameters:
      hex - the hex string
      Returns:
      the byte buffer
    • bytesToHEX

      public static String bytesToHEX​(byte[] bytes)
      Convert a byte buffer to upper case hex character string.
      Parameters:
      bytes - the buffer
      Returns:
      the hex string
    • encoded

      public static String encoded​(byte[] hash)
      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

      public static String encodedT1​(byte[] hash)
      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.