public interface HashCreator extends CryptoChunker
MessageDigest but allows
additional features like hashing in multiple rounds (hashing of hashes) and gives additional abstraction as well as
flexibility.| Modifier and Type | Method and Description |
|---|---|
default byte[] |
hash()
This method calculates the current hash in the cheapest way of the underlying implementation.
|
byte[] |
hash(boolean reset) |
default byte[] |
hash(byte[] input,
boolean reset) |
default byte[] |
hash(byte[] input,
int offset,
int length,
boolean reset) |
default Hash |
hash(CryptoBinary input,
boolean reset) |
default byte[] |
process(byte[] input,
int offset,
int length,
boolean complete)
Generic method to process and transform data.
|
default OutputStream |
wrapStream() |
OutputStream |
wrapStream(OutputStream out)
Creates a new
OutputStream wraps the given OutputStream. |
update, update, updateprocess, process, process, resetgetAlgorithmdefault OutputStream wrapStream()
OutputStream that automatically updates all
written data.wrapStream(OutputStream)OutputStream wrapStream(OutputStream out)
OutputStream wraps the given OutputStream. It will automatically
update all written data. After data has been written,
you may call hash(boolean) to get the hash of the data. This method will not reset this
hasher. Therefore any previous updated data will also influence the hash. The typical usage
is to call this method once on a fresh instance of HashCreator, then write data to that stream and
finally get the hash.out - the OutputStream to wrap.OutputStream.wrapStream(),
DigestOutputStreamdefault byte[] process(byte[] input,
int offset,
int length,
boolean complete)
CryptoProcessorCryptoProcessor |
Equivalent of process(input, offset, length, complete) |
|---|---|
HashCreator |
|
Cryptor |
return |
SignatureSigner |
|
SignatureVerifier |
throw new |
process in interface CryptoProcessorinput - the data to process.offset - the index where to start reading data from input.length - the number of bytes to read from input.complete - - true to complete/reset this processor after processing the given input,
false otherwise.input data.default byte[] hash(byte[] input,
boolean reset)
input - the data to hash.reset - - see hash(boolean).MessageDigest.digest(byte[], int, int)default Hash hash(CryptoBinary input, boolean reset)
input - the data to hash.reset - - see hash(boolean).Hash of the given input data.MessageDigest.digest(byte[], int, int)default byte[] hash(byte[] input,
int offset,
int length,
boolean reset)
input - the data to hash.offset - the index where to start reading data from input.length - the number of bytes to read from input.reset - - see hash(boolean).MessageDigest.digest(byte[], int, int)default byte[] hash()
HashCreator after the call of this method is therefore unspecified. Use this method only if you do
not care about the further state of this HashCreator. Otherwise use hash(boolean) instead.MessageDigest.digest()byte[] hash(boolean reset)
reset - - true if this HashCreator shall be reset after the hash
calculation, false otherwise. A design problem of MessageDigest is that it
automatically resets itself on
hashing what prevents calculating intermediate hashes but also
continue the hash calculation. This API allows to workaround this limitation.MessageDigest.digest()Copyright © 2001–2019 mmm-Team. All rights reserved.