diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/password/DigestPasswordVerifier.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/password/DigestPasswordVerifier.java index 7d3e0ea5..d144fe5f 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/password/DigestPasswordVerifier.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/password/DigestPasswordVerifier.java @@ -4,6 +4,8 @@ import org.apache.logging.log4j.Logger; import pro.gravit.utils.helper.SecurityHelper; +import javax.xml.bind.DatatypeConverter; +import java.io.UnsupportedEncodingException; import java.nio.charset.StandardCharsets; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; @@ -17,8 +19,11 @@ public class DigestPasswordVerifier extends PasswordVerifier { public boolean check(String encryptedPassword, String password) { try { MessageDigest digest = MessageDigest.getInstance(algo); - byte[] bytes = SecurityHelper.fromHex(encryptedPassword); - return Arrays.equals(password.getBytes(StandardCharsets.UTF_8), digest.digest(bytes)); + digest.update(password.getBytes(StandardCharsets.UTF_8)); + byte[] bytes = digest.digest(); + String myHash = DatatypeConverter + .printHexBinary(bytes); + return myHash.equalsIgnoreCase(encryptedPassword); } catch (NoSuchAlgorithmException e) { logger.error("Digest algorithm {} not supported", algo); return false;