2013-10-17 05:14:46 +02:00
|
|
|
package fr.xephi.authme.security.crypts;
|
2013-06-20 02:15:27 +02:00
|
|
|
|
2018-09-03 23:13:48 +02:00
|
|
|
import at.favre.lib.crypto.bcrypt.BCrypt.Version;
|
2016-07-23 15:50:40 +02:00
|
|
|
import fr.xephi.authme.settings.Settings;
|
2016-04-23 12:46:30 +02:00
|
|
|
import fr.xephi.authme.settings.properties.HooksSettings;
|
2015-12-26 23:59:32 +01:00
|
|
|
|
2016-04-30 12:17:18 +02:00
|
|
|
import javax.inject.Inject;
|
2013-06-20 02:15:27 +02:00
|
|
|
|
2018-09-03 23:13:48 +02:00
|
|
|
/**
|
|
|
|
* BCrypt hash algorithm with configurable cost factor.
|
|
|
|
*/
|
|
|
|
public class BCrypt extends BCryptBasedHash {
|
2016-04-23 12:46:30 +02:00
|
|
|
|
2016-04-30 12:17:18 +02:00
|
|
|
@Inject
|
2017-03-17 18:49:30 +01:00
|
|
|
public BCrypt(Settings settings) {
|
2018-09-03 23:13:48 +02:00
|
|
|
super(createHasher(settings));
|
2015-12-26 23:59:32 +01:00
|
|
|
}
|
|
|
|
|
2018-09-03 23:13:48 +02:00
|
|
|
private static BCryptHasher createHasher(Settings settings) {
|
|
|
|
int bCryptLog2Rounds = settings.getProperty(HooksSettings.BCRYPT_LOG2_ROUND);
|
|
|
|
return new BCryptHasher(Version.VERSION_2A, bCryptLog2Rounds);
|
2015-12-28 20:10:45 +01:00
|
|
|
}
|
2013-06-20 02:15:27 +02:00
|
|
|
}
|