Package org.cryptacular.bean
Class AbstractHashBean
java.lang.Object
org.cryptacular.bean.AbstractHashBean
- Direct Known Subclasses:
EncodingHashBean,SimpleHashBean
Abstract base class for all hash beans.
- Author:
- Middleware Services
-
Constructor Summary
ConstructorsConstructorDescriptionAbstractHashBean(Spec<org.bouncycastle.crypto.Digest> digestSpec) Creates a new abstract hash bean.AbstractHashBean(Spec<org.bouncycastle.crypto.Digest> digestSpec, int iterations) Creates a new abstract hash bean. -
Method Summary
Modifier and TypeMethodDescriptionprotected booleancompareInternal(byte[] hash, Object... data) Compares the hash of the given data against a known hash output.Spec<org.bouncycastle.crypto.Digest>intprotected byte[]hashInternal(Object... data) Hashes the given data.
-
Constructor Details
-
AbstractHashBean
Creates a new abstract hash bean.- Parameters:
digestSpec- Digest specification.
-
AbstractHashBean
Creates a new abstract hash bean.- Parameters:
digestSpec- Digest specification.iterations- Number of hash rounds.
-
-
Method Details
-
getDigestSpec
- Returns:
- Digest specification that determines the instance of
Digestused to compute the hash.
-
getIterations
public int getIterations()- Returns:
- Number of iterations the digest function is applied to the input data.
-
hashInternal
Hashes the given data.- Parameters:
data- Data to hash.- Returns:
- Digest output.
-
compareInternal
Compares the hash of the given data against a known hash output.- Parameters:
hash- Known hash value. If the length of the array is greater than the length of the digest output, anything beyond the digest length is considered salt data that is hashed after the input data.data- Data to hash.- Returns:
- True if hashed data equals known hash output, false otherwise.
-