BCryptHashingStrategy
class BCryptHashingStrategy implements PasswordHashingStrategyInterface (View source)
Hashing passwords using BCrypt
Properties
protected | $cost | Number of rounds to use with BCrypt for hashing passwords, must be between 4 and 31 |
Methods
__construct(int $cost)
Construct a BCrypt hashing strategy with the given parameters
string
hashPassword(string $password, string|null $staticSalt = null)
Creates a BCrypt hash
bool
validatePassword(string $password, string $hashedPasswordAndSalt, string|null $staticSalt = null)
Validate a password against a derived key (hashed password) and salt using BCrypt
Details
__construct(int $cost)
Construct a BCrypt hashing strategy with the given parameters
string
hashPassword(string $password, string|null $staticSalt = null)
Creates a BCrypt hash
bool
validatePassword(string $password, string $hashedPasswordAndSalt, string|null $staticSalt = null)
Validate a password against a derived key (hashed password) and salt using BCrypt
Passwords hashed with a different cost can be validated by using the cost parameter of the hashed password and salt.