- java.lang.Object
-
- io.github.mmm.crypto.algorithm.AbstractSecurityAlgorithm
-
- io.github.mmm.crypto.algorithm.AbstractCryptoAlgorithmWithProvider
-
- io.github.mmm.crypto.algorithm.CryptoAlgorithmImpl
-
- io.github.mmm.crypto.hash.HashCreatorImplDigest
-
- io.github.mmm.crypto.hash.HashCreatorImplMultipleRounds
-
- All Implemented Interfaces:
CryptoAlgorithm
,CryptoChunker
,CryptoProcessor
,HashCreator
public class HashCreatorImplMultipleRounds extends HashCreatorImplDigest
This is an implementation ofHashCreator
thatcalculates hashes
in multiple rounds. Therefore, the actualdata
is hashed once and then for the number of rounds given at construction time the initial hash is hashed again with the same hash algorithm.- Since:
- 1.0.0
- Author:
- Joerg Hohwiller (hohwille at users.sourceforge.net)
-
-
Field Summary
-
Fields inherited from class io.github.mmm.crypto.algorithm.AbstractCryptoAlgorithmWithProvider
provider
-
-
Constructor Summary
Constructors Constructor Description HashCreatorImplMultipleRounds(String hashAlgorithm, SecurityProvider provider, int iterationCount)
The constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]
hash(boolean reset)
-
Methods inherited from class io.github.mmm.crypto.hash.HashCreatorImplDigest
getOrCloneMessageDigest, reset, update, wrapStream
-
Methods inherited from class io.github.mmm.crypto.algorithm.CryptoAlgorithmImpl
getAlgorithm
-
Methods inherited from class io.github.mmm.crypto.algorithm.AbstractCryptoAlgorithmWithProvider
getProvider
-
Methods inherited from class io.github.mmm.crypto.algorithm.AbstractSecurityAlgorithm
creationFailedException, creationFailedException, creationFailedException, creationFailedException, getAlgorithm, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface io.github.mmm.crypto.algorithm.CryptoAlgorithm
getAlgorithm
-
Methods inherited from interface io.github.mmm.crypto.CryptoChunker
update, update
-
Methods inherited from interface io.github.mmm.crypto.CryptoProcessor
process, process, process
-
Methods inherited from interface io.github.mmm.crypto.hash.HashCreator
hash, hash, hash, hash, process, wrapStream
-
-
-
-
Constructor Detail
-
HashCreatorImplMultipleRounds
public HashCreatorImplMultipleRounds(String hashAlgorithm, SecurityProvider provider, int iterationCount)
The constructor.- Parameters:
hashAlgorithm
- the name of the hash algorithm to use (e.g. "SHA-256").iterationCount
-AbstractGetIterationCount
. Has to be greater than1
.provider
- theSecurityProvider
to use.
-
-
Method Detail
-
hash
public byte[] hash(boolean reset)
- Specified by:
hash
in interfaceHashCreator
- Overrides:
hash
in classHashCreatorImplDigest
- Parameters:
reset
- -true
if thisHashCreator
shall bereset
after the hash calculation,false
otherwise. A design problem ofMessageDigest
is that it automaticallyresets
itself onhashing
what prevents calculating intermediate hashes but also continue the hash calculation. This API allows to workaround this limitation.- Returns:
- the calculated hash of the current data.
- See Also:
MessageDigest.digest()
-
-