Minor - fix some small todo's
This commit is contained in:
@@ -85,12 +85,22 @@ public final class HashUtils {
|
||||
* @param algorithm The algorithm to hash the message with
|
||||
* @return The digest in its hexadecimal representation
|
||||
*/
|
||||
private static String hash(String message, MessageDigestAlgorithm algorithm) {
|
||||
MessageDigest md = getDigest(algorithm);
|
||||
md.reset();
|
||||
md.update(message.getBytes());
|
||||
byte[] digest = md.digest();
|
||||
public static String hash(String message, MessageDigest algorithm) {
|
||||
algorithm.reset();
|
||||
algorithm.update(message.getBytes());
|
||||
byte[] digest = algorithm.digest();
|
||||
return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1, digest));
|
||||
}
|
||||
|
||||
/**
|
||||
* Hash the message with the given algorithm and return the hash in its hexadecimal notation.
|
||||
*
|
||||
* @param message The message to hash
|
||||
* @param algorithm The algorithm to hash the message with
|
||||
* @return The digest in its hexadecimal representation
|
||||
*/
|
||||
private static String hash(String message, MessageDigestAlgorithm algorithm) {
|
||||
return hash(message, getDigest(algorithm));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,14 +1,17 @@
|
||||
package fr.xephi.authme.security.crypts;
|
||||
|
||||
import fr.xephi.authme.security.HashUtils;
|
||||
import fr.xephi.authme.security.MessageDigestAlgorithm;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
|
||||
public class RoyalAuth extends UnsaltedMethod {
|
||||
|
||||
@Override
|
||||
public String computeHash(String password) {
|
||||
for (int i = 0; i < 25; i++) {
|
||||
// TODO ljacqu 20151228: HashUtils#sha512 gets a new message digest each time...
|
||||
password = HashUtils.sha512(password);
|
||||
MessageDigest algorithm = HashUtils.getDigest(MessageDigestAlgorithm.SHA512);
|
||||
for (int i = 0; i < 25; ++i) {
|
||||
password = HashUtils.hash(password, algorithm);
|
||||
}
|
||||
return password;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user