类 BCryptUtil
- java.lang.Object
-
- cn.bbwres.biscuit.utils.BCryptUtil
-
public class BCryptUtil extends Object
加密工具- 作者:
- zhanglinfeng
-
-
构造器概要
构造器 构造器 说明 BCryptUtil()
-
方法概要
所有方法 静态方法 具体方法 修饰符和类型 方法 说明 static booleancheckpw(byte[] passwordb, String hashed)Check that a password (as a byte array) matches a previously hashed onestatic booleancheckpw(String plaintext, String hashed)Check that a plaintext password matches a previously hashed onestatic Stringgensalt()Generate a salt for use with the BCrypt.hashpw() method, selecting a reasonable default for the number of hashing rounds to applystatic Stringgensalt(int log_rounds)Generate a salt for use with the BCrypt.hashpw() methodstatic Stringgensalt(int log_rounds, SecureRandom random)Generate a salt for use with the BCrypt.hashpw() methodstatic Stringgensalt(String prefix)static Stringgensalt(String prefix, int log_rounds)Generate a salt for use with the BCrypt.hashpw() methodstatic Stringgensalt(String prefix, int log_rounds, SecureRandom random)Generate a salt for use with the BCrypt.hashpw() methodstatic Stringhashpw(byte[] passwordb, String salt)Hash a password using the OpenBSD bcrypt schemestatic Stringhashpw(String password, String salt)Hash a password using the OpenBSD bcrypt scheme
-
-
-
方法详细资料
-
hashpw
public static String hashpw(String password, String salt)
Hash a password using the OpenBSD bcrypt scheme- 参数:
password- the password to hashsalt- the salt to hash with (perhaps generated using BCrypt.gensalt)- 返回:
- the hashed password
-
hashpw
public static String hashpw(byte[] passwordb, String salt)
Hash a password using the OpenBSD bcrypt scheme- 参数:
passwordb- the password to hash, as a byte arraysalt- the salt to hash with (perhaps generated using BCrypt.gensalt)- 返回:
- the hashed password
-
gensalt
public static String gensalt(String prefix, int log_rounds, SecureRandom random) throws IllegalArgumentException
Generate a salt for use with the BCrypt.hashpw() method- 参数:
prefix- the prefix value (default $2a)log_rounds- the log2 of the number of rounds of hashing to apply - the work factor therefore increases as 2**log_rounds.random- an instance of SecureRandom to use- 返回:
- an encoded salt value
- 抛出:
IllegalArgumentException- if prefix or log_rounds is invalid
-
gensalt
public static String gensalt(String prefix, int log_rounds) throws IllegalArgumentException
Generate a salt for use with the BCrypt.hashpw() method- 参数:
prefix- the prefix value (default $2a)log_rounds- the log2 of the number of rounds of hashing to apply - the work factor therefore increases as 2**log_rounds.- 返回:
- an encoded salt value
- 抛出:
IllegalArgumentException- if prefix or log_rounds is invalid
-
gensalt
public static String gensalt(int log_rounds, SecureRandom random) throws IllegalArgumentException
Generate a salt for use with the BCrypt.hashpw() method- 参数:
log_rounds- the log2 of the number of rounds of hashing to apply - the work factor therefore increases as 2**log_rounds.random- an instance of SecureRandom to use- 返回:
- an encoded salt value
- 抛出:
IllegalArgumentException- if log_rounds is invalid
-
gensalt
public static String gensalt(int log_rounds) throws IllegalArgumentException
Generate a salt for use with the BCrypt.hashpw() method- 参数:
log_rounds- the log2 of the number of rounds of hashing to apply - the work factor therefore increases as 2**log_rounds.- 返回:
- an encoded salt value
- 抛出:
IllegalArgumentException- if log_rounds is invalid
-
gensalt
public static String gensalt()
Generate a salt for use with the BCrypt.hashpw() method, selecting a reasonable default for the number of hashing rounds to apply- 返回:
- an encoded salt value
-
checkpw
public static boolean checkpw(String plaintext, String hashed)
Check that a plaintext password matches a previously hashed one- 参数:
plaintext- the plaintext password to verifyhashed- the previously-hashed password- 返回:
- true if the passwords match, false otherwise
-
checkpw
public static boolean checkpw(byte[] passwordb, String hashed)Check that a password (as a byte array) matches a previously hashed one- 参数:
passwordb- the password to verify, as a byte arrayhashed- the previously-hashed password- 返回:
- true if the passwords match, false otherwise
- 从以下版本开始:
- 5.3
-
-