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