#369 Fix bcrypt 2y implementation

- Change salt length to 22: it was once changed on accident during some other commit
This commit is contained in:
ljacqu
2015-12-28 21:03:33 +01:00
parent 48d0a65724
commit 73bc6e286a
3 changed files with 23 additions and 21 deletions
@@ -4,19 +4,24 @@ import fr.xephi.authme.security.crypts.description.Recommendation;
import fr.xephi.authme.security.crypts.description.Usage;
@Recommendation(Usage.DOES_NOT_WORK)
public class BCRYPT2Y implements EncryptionMethod {
public class BCRYPT2Y extends HexSaltedMethod {
@Override
public String computeHash(String password, String salt, String name) {
if (salt.length() == 22)
salt = "$2y$10$" + salt;
return (BCRYPT.hashpw(password, salt));
return BCRYPT.hashpw(password, salt);
}
@Override
public boolean comparePassword(String hash, String password, String playerName) {
public boolean comparePassword(String hash, String password, String salt, String playerName) {
String ok = hash.substring(0, 29);
return ok.length() == 29 && hash.equals(computeHash(password, ok, playerName));
}
@Override
public int getSaltLength() {
return 22;
}
}