Class MessageDigestHasher

java.lang.Object
org.tribuo.hash.Hasher
org.tribuo.hash.MessageDigestHasher
All Implemented Interfaces:
com.oracle.labs.mlrg.olcut.config.Configurable, com.oracle.labs.mlrg.olcut.provenance.Provenancable<com.oracle.labs.mlrg.olcut.provenance.ConfiguredObjectProvenance>, Serializable

public final class MessageDigestHasher extends Hasher
Hashes Strings using the supplied MessageDigest type.
See Also:
  • Field Details

  • Constructor Details

    • MessageDigestHasher

      public MessageDigestHasher(String hashType, String salt)
      Constructs a message digest hasher.
      Parameters:
      hashType - The hash function to use.
      salt - The salt value.
  • Method Details

    • postConfig

      public void postConfig() throws com.oracle.labs.mlrg.olcut.config.PropertyException
      Used by the OLCUT configuration system, and should not be called by external code.
      Throws:
      com.oracle.labs.mlrg.olcut.config.PropertyException
    • hash

      public String hash(String input)
      Description copied from class: Hasher
      Hashes the supplied input using the hashing function.
      Specified by:
      hash in class Hasher
      Parameters:
      input - The input to hash.
      Returns:
      A String representation of the hashed output.
    • setSalt

      public void setSalt(String salt)
      Description copied from class: Hasher
      The salt is transient, it must be set **to the same value as it was trained with** after the Model is deserialized.
      Specified by:
      setSalt in class Hasher
      Parameters:
      salt - Salt value.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getProvenance

      public com.oracle.labs.mlrg.olcut.provenance.ConfiguredObjectProvenance getProvenance()
    • getDigestSupplier

      public static Supplier<MessageDigest> getDigestSupplier(String hashType)
      Creates a supplier for the specified hash type.
      Parameters:
      hashType - The hash type, used to specify the MessageDigest implementation.
      Returns:
      A supplier for the MessageDigest.