public class BCryptUtil
extends java.lang.Object
Wraps jBCrypt implementation.
| Constructor and Description |
|---|
BCryptUtil() |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
checkBCrypt(java.lang.String candidate_plaintext,
java.lang.String hash,
int minLog2Rounds,
int maxLog2Rounds)
Check a plain text string against an string encrypted using BCrypt.
|
static java.lang.String |
crypt(java.lang.String str,
int log2Rounds)
Hash the specified string with the BCrypt encryption algorithm.
|
static boolean |
isBCryptHash(java.lang.String str)
Check if specified string has the expect syntax of a BCrypt hash.
|
public static java.lang.String crypt(java.lang.String str,
int log2Rounds)
Use checkBCrypt(String, String, int, int) method to verify the encrypted version against a plain text entry.
str - the String to encryptlog2Rounds - the log2 of the number of rounds of hashing to apply - the work factor therefore increases as 2**log_rounds. Authorized value is between 4 and 30 (included)checkBCrypt(String, String, int, int)public static boolean checkBCrypt(java.lang.String candidate_plaintext,
java.lang.String hash,
int minLog2Rounds,
int maxLog2Rounds)
This methods ensure that the specified bcrypt hash respects specified BCrypt security settings.
candidate_plaintext - the plain text to be tested (information usually received from the client, eg : a plain text password recevied from a login form)hash - the encrypted version (information known only on the server side, eg : member.getPassword())minLog2Rounds - the mininum log2 of the number of rounds of hashing authorized in the hash for it to be accepted (specified value is inclusive)maxLog2Rounds - the maximum log2 of the number of rounds of hashing authorized in the hash for it to be accepted (specified value is inclusive)public static boolean isBCryptHash(java.lang.String str)
Note : this method only performs a "surface" check and does NOT verify that the specified string is really a BCrypt hash nor that it is valid. Only use for preliminary verification.
str - the string to checkCopyright © 2001-2022 Jalios SA. All Rights Reserved.