public class BCryptPasswordEncoder extends Object implements PasswordHasher
| Modifier and Type | Class and Description |
|---|---|
static class |
BCryptPasswordEncoder.BCryptVersion
Stores the default bcrypt version for use in configuration.
|
| Constructor and Description |
|---|
BCryptPasswordEncoder() |
BCryptPasswordEncoder(BCryptPasswordEncoder.BCryptVersion version) |
BCryptPasswordEncoder(BCryptPasswordEncoder.BCryptVersion version,
int strength) |
BCryptPasswordEncoder(BCryptPasswordEncoder.BCryptVersion version,
int strength,
SecureRandom random) |
BCryptPasswordEncoder(BCryptPasswordEncoder.BCryptVersion version,
SecureRandom random) |
BCryptPasswordEncoder(int strength) |
BCryptPasswordEncoder(int strength,
SecureRandom random) |
| Modifier and Type | Method and Description |
|---|---|
String |
encode(CharSequence rawPassword)
Encode the raw password.
|
boolean |
matches(CharSequence rawPassword,
String encodedPassword)
Verify the encoded password obtained from storage matches the submitted raw
password after it too is encoded.
|
String |
toString() |
boolean |
upgradeEncoding(String encodedPassword)
Returns true if the encoded password should be encoded again for better security,
else false.
|
public BCryptPasswordEncoder()
public BCryptPasswordEncoder(int strength)
strength - the log rounds to use, between 4 and 31public BCryptPasswordEncoder(BCryptPasswordEncoder.BCryptVersion version)
version - the version of bcrypt, can be 2a,2b,2ypublic BCryptPasswordEncoder(BCryptPasswordEncoder.BCryptVersion version, SecureRandom random)
version - the version of bcrypt, can be 2a,2b,2yrandom - the secure random instance to usepublic BCryptPasswordEncoder(int strength,
SecureRandom random)
strength - the log rounds to use, between 4 and 31random - the secure random instance to usepublic BCryptPasswordEncoder(BCryptPasswordEncoder.BCryptVersion version, int strength)
version - the version of bcrypt, can be 2a,2b,2ystrength - the log rounds to use, between 4 and 31public BCryptPasswordEncoder(BCryptPasswordEncoder.BCryptVersion version, int strength, SecureRandom random)
version - the version of bcrypt, can be 2a,2b,2ystrength - the log rounds to use, between 4 and 31random - the secure random instance to usepublic String encode(CharSequence rawPassword)
encode in interface PasswordHasherrawPassword - the raw password to encodepublic boolean matches(CharSequence rawPassword, String encodedPassword)
matches in interface PasswordHasherrawPassword - the raw password to encode and matchencodedPassword - the encoded password from storage to compare withpublic boolean upgradeEncoding(String encodedPassword)
encodedPassword - the encoded password to checkCopyright © 2020. All rights reserved.