Package: Cryptography
Class: BCrypt
Introduction
Environment: container
Bcrypt is a cryptographic hash function designed for password hashing and safe storing in the backend of applications in a way that is less susceptible to dictionary-based cyberattacks.
It accepts the following attributes
identifier
: the hash alogorithm identifier, it can be'2a'
or'2b'
. The default value is'2b'
.password
: The plain text password to be hashed.round
: A numeric cost is added in front of the salt and the password hashes, showing how many password iterations were made before the hash was generate. The default value is12
.salt
: A 16-byte salt value is added in front of the plain text password, it is random by default.
After configuring the attributes, the token
method can be leveraged to obtain the hashed password.
For example:
Instance Method
Category: accessing
identifier
- Get the identifier of the BCrypt.identifier:
- Set the identifier of the BCrypt.password
- Get the password of the BCrypt.password:
- Set the password of the BCrypt.round
- Get the round of the BCrypt.round:
- Set the round of the BCrypt.salt
- Get the salt of the BCrypt.salt:
- Set the salt of the BCrypt.
Category: encode
token
- Answer the hashed password as a string.For example:
Last updated