public class SimpleHashBean extends AbstractHashBean implements HashBean<byte[]>
Digest
specified by AbstractHashBean.setDigestSpec(org.cryptacular.spec.Spec)
.Constructor and Description |
---|
SimpleHashBean()
Creates a new instance.
|
SimpleHashBean(Spec<org.bouncycastle.crypto.Digest> digestSpec,
int iterations)
Creates a new instance by specifying all properties.
|
Modifier and Type | Method and Description |
---|---|
boolean |
compare(byte[] hash,
Object... data)
Compares a known hash value with the hash of the given data.
|
byte[] |
hash(Object... data)
Hashes the given data.
|
compareInternal, getDigestSpec, getIterations, hashInternal, setDigestSpec, setIterations
public SimpleHashBean()
public SimpleHashBean(Spec<org.bouncycastle.crypto.Digest> digestSpec, int iterations)
digestSpec
- Digest specification.iterations
- Number of hash rounds.public byte[] hash(Object... data) throws CryptoException, StreamException
HashBean
hash
in interface HashBean<byte[]>
data
- Data to hash. Callers should expect support for at least the following types: byte[]
,
CharSequence
, InputStream
, and Resource
. Unless
otherwise noted, character data is processed in the UTF-8
character set; if another
character set is desired, the caller should convert to byte[]
and provide the resulting
bytes.CryptoException
- on hash computation errors.StreamException
- on stream IO errors.public boolean compare(byte[] hash, Object... data) throws CryptoException, StreamException
compare
in interface HashBean<byte[]>
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.CryptoException
- on hash computation errors.StreamException
- on stream IO errors.Copyright © 2003-2024 Virginia Tech. All Rights Reserved.