Package org.cryptacular.bean
Class SimpleHashBean
java.lang.Object
org.cryptacular.bean.AbstractHashBean
org.cryptacular.bean.SimpleHashBean
- All Implemented Interfaces:
HashBean<byte[]>
Computes a hash using an instance of
Digest
specified by AbstractHashBean.setDigestSpec(org.cryptacular.spec.Spec)
.- Author:
- Middleware Services
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new instance.SimpleHashBean
(Spec<org.bouncycastle.crypto.Digest> digestSpec, int iterations) Creates a new instance by specifying all properties. -
Method Summary
Methods inherited from class org.cryptacular.bean.AbstractHashBean
compareInternal, getDigestSpec, getIterations, hashInternal, setDigestSpec, setIterations
-
Constructor Details
-
SimpleHashBean
public SimpleHashBean()Creates a new instance. -
SimpleHashBean
Creates a new instance by specifying all properties.- Parameters:
digestSpec
- Digest specification.iterations
- Number of hash rounds.
-
-
Method Details
-
hash
Description copied from interface:HashBean
Hashes the given data.- Specified by:
hash
in interfaceHashBean<byte[]>
- Parameters:
data
- Data to hash. Callers should expect support for at least the following types:byte[]
,CharSequence
,InputStream
, andResource
. Unless otherwise noted, character data is processed in theUTF-8
character set; if another character set is desired, the caller should convert tobyte[]
and provide the resulting bytes.- Returns:
- Digest output.
- Throws:
CryptoException
- on hash computation errors.StreamException
- on stream IO errors.
-
compare
Compares a known hash value with the hash of the given data.- Specified by:
compare
in interfaceHashBean<byte[]>
- 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 the hashed data matches the given hash, false otherwise.
- Throws:
CryptoException
- on hash computation errors.StreamException
- on stream IO errors.
-