public class BCrypt extends Object
| Constructor and Description |
|---|
BCrypt() |
BCrypt(int strength) |
BCrypt(int strength,
SecureRandom random) |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
checkpw(String plaintext,
String hashed)
Check that a plaintext password matches a previously hashed first
|
String |
encode(CharSequence rawPassword) |
static String |
gensalt()
Generate a salt for use with the Blowfish.hashpw() method, selecting a reasonable
default for the number of hashing rounds to apply
|
static String |
gensalt(int log_rounds)
Generate a salt for use with the Blowfish.hashpw() method
|
static String |
gensalt(int log_rounds,
SecureRandom random)
Generate a salt for use with the Blowfish.hashpw() method
|
static String |
hashpw(String password)
生成密文,使用长度为10的加盐方式
|
static String |
hashpw(String password,
String salt)
生成密文
|
boolean |
matches(CharSequence rawPassword,
String encodedPassword) |
public BCrypt()
public BCrypt(int strength)
strength - the log rounds to use, between 4 and 31public BCrypt(int strength,
SecureRandom random)
strength - the log rounds to use, between 4 and 31random - the secure random instance to usepublic static String hashpw(String password)
password - 需要加密的明文public static String hashpw(String password, String salt)
password - 需要加密的明文salt - 盐,使用gensalt() 生成public static String gensalt(int log_rounds, SecureRandom random)
log_rounds - the log2 of the number of rounds of hashing to apply - the work
factor therefore increases as 2**log_rounds. Minimum 4, maximum 31.random - an instance of SecureRandom to usepublic static String gensalt(int log_rounds)
log_rounds - the log2 of the number of rounds of hashing to apply - the work
factor therefore increases as 2**log_rounds. Minimum 4, maximum 31.public static String gensalt()
public static boolean checkpw(String plaintext, String hashed)
plaintext - the plaintext password to verifyhashed - the previously-hashed passwordpublic String encode(CharSequence rawPassword)
public boolean matches(CharSequence rawPassword, String encodedPassword)
Copyright © 2019. All rights reserved.