public final class MessageDigestGenerator extends AbstractMessageDigestGenerator
HashCodeGenerator which is used to
generate hash values for Java objects.DEFAULT_ALGORITHM| Constructor and Description |
|---|
MessageDigestGenerator()
Create a default hash generator with the default algorithm.
|
MessageDigestGenerator(EMessageDigestAlgorithm... aAlgorithms)
Create a hash generator with a set of possible algorithms to use.
|
MessageDigestGenerator(String sProvider)
Create a default hash generator with the default algorithm and the
specified security provider
|
MessageDigestGenerator(String sProvider,
EMessageDigestAlgorithm... aAlgorithms)
Create a hash generator with a set of possible algorithms to use.
|
| Modifier and Type | Method and Description |
|---|---|
String |
getAlgorithmName() |
byte[] |
getAllDigestBytes()
Finish calculation of the hash value and return the digest.
|
byte[] |
getAllDigestBytes(int nLength)
Get only a part of the digest, namely the first number of bytes.
|
int |
getDigestLength() |
Provider |
getSecurityProvider() |
void |
reset()
Reset the current hash so that generation can start from scratch again.
|
String |
toString() |
MessageDigestGenerator |
update(byte aValue)
Update the hash with the given byte.
|
MessageDigestGenerator |
update(byte[] aValue,
int nOffset,
int nLength)
Update the hash with a slice of the given byte array.
|
getDigestHexString, getDigestLong, update, updatepublic MessageDigestGenerator()
public MessageDigestGenerator(@Nullable String sProvider)
sProvider - Security provider to be used. May be null to indicate
the default.public MessageDigestGenerator(@Nonnull@Nonempty EMessageDigestAlgorithm... aAlgorithms)
aAlgorithms - The parameters to test. May not be null.NullPointerException - If the array of algorithms is null or if one element
of the array is null.IllegalArgumentException - If no algorithm was passed or if no applicable algorithm was used.public MessageDigestGenerator(@Nullable String sProvider, @Nonnull@Nonempty EMessageDigestAlgorithm... aAlgorithms)
sProvider - Security provider to be used. May be null to indicate
the default.aAlgorithms - The parameters to test. May not be null.NullPointerException - If the array of algorithms is null or if one element
of the array is null.IllegalArgumentException - If no algorithm was passed or if no applicable algorithm was used.@Nonnull public Provider getSecurityProvider()
null.@Nonnull public String getAlgorithmName()
@Nonnegative public int getDigestLength()
@Nonnull public MessageDigestGenerator update(byte aValue)
IMessageDigestGeneratorIMessageDigestGenerator.getAllDigestBytes() once, no further update is possible.aValue - The byte value to update the hash@Nonnull public MessageDigestGenerator update(@Nonnull byte[] aValue, @Nonnegative int nOffset, @Nonnegative int nLength)
IMessageDigestGeneratorIMessageDigestGenerator.getAllDigestBytes() once, no further update is possible.aValue - The byte array to update the hash. May not be null.nOffset - The offset within the byte array from which the value should be
taken. May not be < 0.nLength - The number of bytes to use, starting from the passed offset. May not
be < 0.public void reset()
IMessageDigestGenerator@Nonnull @ReturnsMutableCopy public byte[] getAllDigestBytes()
IMessageDigestGeneratorIMessageDigestGenerator.reset() is called.@Nonnull @ReturnsMutableCopy public byte[] getAllDigestBytes(@Nonnegative int nLength)
IMessageDigestGeneratorIMessageDigestGenerator.getAllDigestBytes() internally so no further update is possible
after this method is called.nLength - The number of bytes to be retrieved. Must be > 0.Copyright © 2014–2015 Philip Helger. All rights reserved.