Allow Digester iterations to update
Fixes gh-4676
This commit is contained in:
@@ -31,7 +31,7 @@ final class Digester {
|
||||
|
||||
private final String algorithm;
|
||||
|
||||
private final int iterations;
|
||||
private int iterations;
|
||||
|
||||
/**
|
||||
* Create a new Digester.
|
||||
@@ -42,7 +42,7 @@ final class Digester {
|
||||
// eagerly validate the algorithm
|
||||
createDigest(algorithm);
|
||||
this.algorithm = algorithm;
|
||||
this.iterations = iterations;
|
||||
setIterations(iterations);
|
||||
}
|
||||
|
||||
public byte[] digest(byte[] value) {
|
||||
@@ -53,6 +53,13 @@ final class Digester {
|
||||
return value;
|
||||
}
|
||||
|
||||
final void setIterations(int iterations) {
|
||||
if(iterations <= 0) {
|
||||
throw new IllegalArgumentException("Iterations value must be greater than zero");
|
||||
}
|
||||
this.iterations = iterations;
|
||||
}
|
||||
|
||||
private static MessageDigest createDigest(String algorithm) {
|
||||
try {
|
||||
return MessageDigest.getInstance(algorithm);
|
||||
|
||||
Reference in New Issue
Block a user