public class BCryptPasswordEncryptor extends Object implements PasswordEncryptor, Serializable
Modifier and Type | Method and Description |
---|---|
boolean |
checkPassword(char[] plainPassword,
String storedPassword)
Checks an unencrypted password against an encrypted one to see if they match.
|
String |
encryptPassword(char[] plainPassword)
Encrypts a password.
|
int |
getCostFactor()
Returns the cost factor in use by this instance.
|
static BCryptPasswordEncryptor |
newInstance(int costFactor)
Returns a password encryptor that uses the BCrypt algorithm with the specified cost factor.
|
public static final String NAME
public static BCryptPasswordEncryptor newInstance(int costFactor)
costFactor
- the BCrypt cost factor, must be between and
(inclusive).IllegalArgumentException
- if the specified BCrypt cost factor is not between
and (inclusive).public String encryptPassword(char[] plainPassword)
PasswordEncryptor
encryptPassword
in interface PasswordEncryptor
plainPassword
- the plaintext password as a cleanable char[]public boolean checkPassword(char[] plainPassword, String storedPassword)
PasswordEncryptor
checkPassword
in interface PasswordEncryptor
plainPassword
- the plaintext password as a cleanable char[]storedPassword
- the (BASE-64) digest from an earlier encryption against which to check the plaintext passwordpublic int getCostFactor()
OACC is a Java Application Security Framework developed by Acciente, LLC., released under Apache License 2.0.
Copyright 2009-2017, Acciente, LLC.