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.
|
| Modifier and Type | Method and Description |
|---|---|
String |
getAlgorithmName() |
byte[] |
getDigest()
Finish calculation of the hash value and return the digest.
|
byte[] |
getDigest(int nLength)
Get only a part of the digest, namely the first number of bytes.
|
int |
getDigestLength() |
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, update, updatepublic MessageDigestGenerator()
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.@Nonnull public String getAlgorithmName()
@Nonnegative public int getDigestLength()
@Nonnull public MessageDigestGenerator update(byte aValue)
IMessageDigestGeneratorIMessageDigestGenerator.getDigest()
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.getDigest() 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[] getDigest()
IMessageDigestGeneratorIMessageDigestGenerator.reset() is called.@Nonnull @ReturnsMutableCopy public byte[] getDigest(@Nonnegative int nLength)
IMessageDigestGeneratorIMessageDigestGenerator.getDigest() internally so no further update is possible after this
method is called.nLength - The number of bytes to be retrieved. Must be > 0.Copyright © 2006–2014 phloc systems. All rights reserved.