mirror of
https://e.coding.net/circlecloud/AuthMe.git
synced 2025-11-26 21:46:23 +00:00
26
src/main/java/fr/xephi/authme/security/crypts/SHA512.java
Normal file
26
src/main/java/fr/xephi/authme/security/crypts/SHA512.java
Normal file
@@ -0,0 +1,26 @@
|
||||
package fr.xephi.authme.security.crypts;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
public class SHA512 implements EncryptionMethod {
|
||||
|
||||
private static String getSHA512(String message) throws NoSuchAlgorithmException {
|
||||
MessageDigest sha512 = MessageDigest.getInstance("SHA-512");
|
||||
sha512.reset();
|
||||
sha512.update(message.getBytes());
|
||||
byte[] digest = sha512.digest();
|
||||
return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1, digest));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean comparePassword(String hash, String password, String playerName) throws NoSuchAlgorithmException {
|
||||
return hash.equals(getHash(password, "", ""));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHash(String password, String salt, String name) throws NoSuchAlgorithmException {
|
||||
return getSHA512(password);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user