Package com.exedio.cope.pattern
Interface HashAlgorithm
public interface HashAlgorithm
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Returns whether the given plain text matches the given hash.constrainStorage
(StringField storage) Constrains the field used to store the hash.Return a description of the algorithm.getID()
Returns an id for that algorithm.Returns a hash for the given plain text.
-
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 tocheck
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 bygetID()
. -
constrainStorage
Constrains the field used to store the hash. All hashes created MUST not violateField.check(Object)
forStringField
. -
hash
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
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.
-