Package cn.dev33.satoken.secure
Class BCrypt
java.lang.Object
cn.dev33.satoken.secure.BCrypt
Deprecated.
BCrypt加密算法实现。由它加密的文件可在所有支持的操作系统和处理器上进行转移。它的口令必须是8至56个字符,并将在内部被转化为448位的密钥。
此类来自于https://github.com/jeremyh/jBCrypt/
使用方法如下:
String pw_hash = BCrypt.hashpw(plain_password, BCrypt.gensalt());
使用checkpw方法检查被加密的字符串是否与原始字符串匹配:
BCrypt.checkpw(candidate_password, stored_hash);
gensalt方法提供了可选参数 (log_rounds) 来定义加盐多少,也决定了加密的复杂度:
String strong_salt = BCrypt.gensalt(10);
String stronger_salt = BCrypt.gensalt(12);
- Since:
- 1.29.0
- Author:
- Damien Miller
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanDeprecated.检查明文密码文本是否匹配加密后的文本byte[]crypt(byte[] password, byte[] salt, int log_rounds, int[] cdata) Deprecated.加密密文static Stringgensalt()Deprecated.生成盐static Stringgensalt(int log_rounds) Deprecated.生成盐static Stringgensalt(int log_rounds, SecureRandom random) Deprecated.生成盐static StringDeprecated.生成密文,使用长度为10的加盐方式static StringDeprecated.生成密文
-
Constructor Details
-
BCrypt
public BCrypt()Deprecated.
-
-
Method Details
-
crypt
public byte[] crypt(byte[] password, byte[] salt, int log_rounds, int[] cdata) Deprecated.加密密文- Parameters:
password- 明文密码salt- 加盐log_rounds- hash中叠加的对数cdata- 加密数据- Returns:
- 加密后的密文
-
hashpw
Deprecated.生成密文,使用长度为10的加盐方式- Parameters:
password- 需要加密的明文- Returns:
- 密文
-
hashpw
Deprecated.生成密文- Parameters:
password- 需要加密的明文salt- 盐,使用gensalt()生成- Returns:
- 密文
-
gensalt
Deprecated.生成盐- Parameters:
log_rounds- hash中叠加的2的对数 - the work factor therefore increases as 2**log_rounds.random-SecureRandom- Returns:
- an encoded salt value
-
gensalt
Deprecated.生成盐- Parameters:
log_rounds- the log2 of the number of rounds of hashing to apply - the work factor therefore increases as 2**log_rounds.- Returns:
- 盐
-
gensalt
Deprecated.生成盐- Returns:
- 盐
-
checkpw
Deprecated.检查明文密码文本是否匹配加密后的文本- Parameters:
plaintext- 需要验证的明文密码hashed- 密文- Returns:
- 是否匹配
-