| Modifier and Type | Field and Description |
|---|---|
int |
allowedMaxPwLength
The max allowed length of password in bcrypt, longer than that
LongPasswordStrategy will be activated. |
boolean |
appendNullTerminator
Since OpenBSD bcrypt version $2a$ a null-terminator byte must be append to the hash.
|
static int |
DEFAULT_MAX_PW_LENGTH_BYTE
Deprecated.
this will return 71 which is not correct, the null terminator should not count towards the full length if the pw is exactly 72. Use
MAX_PW_LENGTH_BYTE instead. See https://github.com/patrickfav/bcrypt/pull/44 |
BCryptFormatter |
formatter
The formatter for the bcrypt message digest
|
static int |
MAX_PW_LENGTH_BYTE
Absolutely maximum length bcrypt can support (18x32bit).
|
BCryptParser |
parser
The parser used to parse a bcrypt message
|
static List<BCrypt.Version> |
SUPPORTED_VERSIONS
List of supported versions
|
boolean |
useOnly23bytesForHash
Due to a bug the OpenBSD implemenation only uses 23 bytes (184 bit) of the possible 24 byte output from
blowfish.
|
static BCrypt.Version |
VERSION_2A
$2a$
|
static BCrypt.Version |
VERSION_2B
$2b$ (2014/02)
|
static BCrypt.Version |
VERSION_2X
$2x$ (2011)
|
static BCrypt.Version |
VERSION_2Y
$2y$ (2011)
|
static BCrypt.Version |
VERSION_2Y_NO_NULL_TERMINATOR
$2y$ (2011) without the null terminator
|
static BCrypt.Version |
VERSION_BC
This mirrors how Bouncy Castle creates bcrypt hashes: with 24 byte out and without null-terminator.
|
byte[] |
versionIdentifier
Version identifier byte array, eg.{0x32, 0x61} for '2a'
|
| Constructor and Description |
|---|
Version(byte[] versionIdentifier,
boolean useOnly23bytesForHash,
boolean appendNullTerminator,
int allowedMaxPwLength,
BCryptFormatter formatter,
BCryptParser parser)
Create a new version.
|
public static final int MAX_PW_LENGTH_BYTE
@Deprecated public static final int DEFAULT_MAX_PW_LENGTH_BYTE
MAX_PW_LENGTH_BYTE instead. See https://github.com/patrickfav/bcrypt/pull/44public static final BCrypt.Version VERSION_2A
The original specification did not define how to handle non-ASCII character, nor how to handle a null terminator. The specification was revised to specify that when hashing strings: - the string must be UTF-8 encoded - the null terminator must be included
public static final BCrypt.Version VERSION_2B
A bug was discovered in the OpenBSD implementation of bcrypt. They were storing the length of their strings in an unsigned char (i.e. 8-bit Byte). If a password was longer than 255 characters, it would overflow and wrap at 255. To recognize possible incorrect hashes, a new version was created.
public static final BCrypt.Version VERSION_2X
Due to a bug in crypt_blowfish, a PHP implementation of BCrypt, a new version string was introduced to recognize old hashes. It was mis-handling characters with the 8th bit set. Nobody else, including canonical OpenBSD, adopted the idea of 2x/2y so this version marker change was limited to crypt_blowfish.
Nobody else, including canonical OpenBSD, adopted the idea of 2x/2y. This version marker change was limited to crypt_blowfish.
public static final BCrypt.Version VERSION_2Y
See VERSION_2X
public static final BCrypt.Version VERSION_2Y_NO_NULL_TERMINATOR
See VERSION_2Y
public static final BCrypt.Version VERSION_BC
public static final List<BCrypt.Version> SUPPORTED_VERSIONS
public final byte[] versionIdentifier
public final boolean useOnly23bytesForHash
public final boolean appendNullTerminator
public final int allowedMaxPwLength
LongPasswordStrategy will be activated.
Usual lengths are between 50 and 72 bytes, most often are 56, 71 or 72 bytes.
See https://security.stackexchange.com/a/39851public final BCryptFormatter formatter
public final BCryptParser parser
public Version(byte[] versionIdentifier,
boolean useOnly23bytesForHash,
boolean appendNullTerminator,
int allowedMaxPwLength,
BCryptFormatter formatter,
BCryptParser parser)
VERSION_2A, VERSION_2Y etc.versionIdentifier - version as UTF-8 encoded byte array, e.g. '2a' = new byte[]{0x32, 0x61}, do not included the separator '$'useOnly23bytesForHash - set to false if you want the full 24 byte out for the hash (otherwise will be truncated to 23 byte according to OpenBSD impl)appendNullTerminator - as defined in $2a$+ a null terminator is appended to the password, pass false if you want avoid thisallowedMaxPwLength - the max allowed length of password in bcrypt, longer than that LongPasswordStrategy will be activatedformatter - the formatter responsible for formatting the out hash message digestparser - responsible for parsing the message formatCopyright © 2018–2023. All rights reserved.