Interface HashAlgorithm


public interface HashAlgorithm
  • Method Details

    • getID

      String getID()
      Returns an id for that algorithm. For any set of algorithms returning the same id any algorithm of that set should be able to check any hashes created by any other algorithm of that set.
    • getDescription

      String getDescription()
      Return a description of the algorithm. May contain additional info, that does not prevent hashing compatibility required by getID().
    • constrainStorage

      StringField constrainStorage(StringField storage)
      Constrains the field used to store the hash. All hashes created MUST not violate Field.check(Object) for StringField.
    • hash

      String hash(String plainText)
      Returns a hash for the given plain text. The result is not required to be deterministic - this means, multiple calls for the same plain text do not have to return the same hash. This is especially true for salted hashes.
      Parameters:
      plainText - the text to be hashed. Is never null.
      Returns:
      the hash of plainText. Must never return null.
    • check

      boolean check(String plainText, String hash)
      Returns whether the given plain text matches the given hash.
      Parameters:
      plainText - the text to be hashed. Is never null.
      hash - the hash of plainText. Is never null.