#358 Create encryption method supertypes, add new methods

This commit is contained in:
ljacqu
2015-12-28 20:10:45 +01:00
parent 31730699ac
commit 48d0a65724
43 changed files with 551 additions and 524 deletions
@@ -0,0 +1,35 @@
package fr.xephi.authme.security.crypts;
/**
* Common supertype for encryption methods which store their salt separately from the hash.
*/
public abstract class SeparateSaltMethod implements NewEncrMethod {
@Override
public abstract String computeHash(String password, String salt, String name);
@Override
public abstract String generateSalt();
@Override
public HashResult computeHash(String password, String name) {
String salt = generateSalt();
return new HashResult(computeHash(password, salt, name), salt);
}
@Override
public boolean comparePassword(String hash, String password, String salt, String name) {
return hash.equals(computeHash(password, salt, null));
}
@Override
public boolean hasSeparateSalt() {
return true;
}
@Override
@Deprecated
public boolean comparePassword(String hash, String password, String playerName) {
return false;
}
}