public class EncodingHashBean extends AbstractHashBean implements HashBean<String>
Constructor and Description |
---|
EncodingHashBean()
Creates a new instance.
|
EncodingHashBean(Spec<Codec> codecSpec,
Spec<org.bouncycastle.crypto.Digest> digestSpec,
int iterations)
Creates a new instance by specifying all properties.
|
Modifier and Type | Method and Description |
---|---|
boolean |
compare(String hash,
Object... data)
Compares a known hash value with the hash of the given data.
|
Spec<Codec> |
getCodecSpec() |
String |
hash(Object... data)
Hashes the given data.
|
void |
setCodecSpec(Spec<Codec> codecSpec)
Sets the codec specification that determines the encoding applied to the
hash output bytes.
|
compareInternal, getDigestSpec, getIterations, hashInternal, setDigestSpec, setIterations
public Spec<Codec> getCodecSpec()
public void setCodecSpec(Spec<Codec> codecSpec)
codecSpec
- Codec specification, e.g. CodecSpec.BASE64
, CodecSpec.HEX
.public String hash(Object... data)
hash
in interface HashBean<String>
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.public boolean compare(String hash, Object... data)
compare
in interface HashBean<String>
hash
- Known encoded hash value. If the length of the hash bytes
after decoding 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.Copyright © 2016 JBoss by Red Hat. All rights reserved.