Class SimpleHashFunction

java.lang.Object
org.hibernate.search.util.common.data.impl.SimpleHashFunction
All Implemented Interfaces:
HashFunction

public final class SimpleHashFunction extends Object implements HashFunction
A fast, but cryptographically insecure hash function, based on Java's String.toString().
  • Field Details

  • Method Details

    • toString

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

      public int hash(CharSequence key)
      Hashes a key, i.e. turns it into an integer for use in a HashTable.

      This implementation is the same hash function as Java's String.toString().

      It does not delegate to String.toString() in order to protect against future changes in the JDK (?) or different JDK implementations, so that the resulting hash can safely be used for persistence (e.g. to route data to a file).

      Specified by:
      hash in interface HashFunction
      Parameters:
      key - A key to hash.
      Returns:
      A hash.