Add bcrypt_2y for new phpbb system

This commit is contained in:
Xephi59
2015-07-31 01:11:34 +02:00
parent 9c42be39d8
commit fa831700a2
3 changed files with 31 additions and 1 deletions
@@ -0,0 +1,24 @@
package fr.xephi.authme.security.crypts;
import java.security.NoSuchAlgorithmException;
public class BCRYPT2Y implements EncryptionMethod {
@Override
public String getHash(String password, String salt, String name)
throws NoSuchAlgorithmException {
if (salt.length() == 22)
salt = "$2y$10$" + salt;
return (BCRYPT.hashpw(password, salt));
}
@Override
public boolean comparePassword(String hash, String password,
String playerName) throws NoSuchAlgorithmException {
String ok = hash.substring(29);
if (ok.length() != 29)
return false;
return hash.equals(getHash(password, ok, playerName));
}
}