Package com.exedio.cope.pattern
Interface Hash.Algorithm
- All Known Implementing Classes:
MessageDigestAlgorithm
- Enclosing class:
- Hash
public static interface Hash.Algorithm
-
Method Summary
Modifier and TypeMethodDescriptionbooleancheck(byte[] plainText, byte[] hash) Returns whether the given plain text matches the given hash.booleancompatibleTo(Hash.Algorithm other) Returns whether this algorithm can consistently check hash values created by the given algorithm.byte[]hash(byte[] plainText) Returns a hash for the given plain text.intlength()name()
-
Method Details
-
name
String name() -
length
int length() -
hash
byte[] hash(byte[] 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(byte[] plainText, byte[] 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.- Throws:
IllegalArgumentException- if hash.length!=length().
-
compatibleTo
Returns whether this algorithm can consistently check hash values created by the given algorithm.- Throws:
NullPointerException- if other is null
-