public class BCrypt extends Object
| Constructor and Description |
|---|
BCrypt() |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
checkpw(String plaintext,
String hashed)
检查明文密码文本是否匹配加密后的文本
|
byte[] |
crypt(byte[] password,
byte[] salt,
int log_rounds,
int[] cdata)
加密密文
|
static String |
gensalt()
生成一个salt以与BCrypt.hashpw()方法一起使用,
为要应用的散列轮数选择一个合理的默认值
|
static String |
gensalt(int log_rounds)
生成用于BCrypt.hashpw()方法的salt
|
static String |
gensalt(int log_rounds,
SecureRandom random)
生成用于BCrypt.hashpw()方法的salt
|
static String |
hashpw(String password)
生成密文,使用长度为10的加盐方式
|
static String |
hashpw(String password,
String salt)
生成密文
|
public static String hashpw(String password)
password - 需要加密的明文public static String hashpw(String password, String salt)
password - 需要加密的明文salt - 盐,使用gensalt() 生成public static String gensalt()
public static String gensalt(int log_rounds)
log_rounds - 要应用的散列的轮数的log2 —— 因此工作因子增加为 2**log_roundsIllegalArgumentException - 如果前缀或log_rounds无效public static String gensalt(int log_rounds, SecureRandom random)
log_rounds - 要应用的散列的轮数的log2 —— 因此工作因子增加为 2**log_roundsrandom - 要使用的SecureRandom实例IllegalArgumentException - 如果前缀或log_rounds无效public static boolean checkpw(String plaintext, String hashed)
plaintext - 需要验证的明文密码hashed - 密文public byte[] crypt(byte[] password,
byte[] salt,
int log_rounds,
int[] cdata)
password - 明文密码salt - 加盐log_rounds - hash中叠加的对数cdata - 加密数据Copyright © 2019. All rights reserved.