PHP Class Neos\Flow\Security\Cryptography\BCryptHashingStrategy

Inheritance: implements Neos\Flow\Security\Cryptography\PasswordHashingStrategyInterface
Mostra file Open project: neos/flow-development-collection Class Usage Examples

Protected Properties

Property Type Description
$cost integer Number of rounds to use with BCrypt for hashing passwords, must be between 4 and 31

Public Methods

Method Description
__construct ( integer $cost ) Construct a PBKDF2 hashing strategy with the given parameters
hashPassword ( string $password, string $staticSalt = null ) : string Creates a BCrypt hash
validatePassword ( string $password, string $hashedPasswordAndSalt, string $staticSalt = null ) : boolean Validate a password against a derived key (hashed password) and salt using BCrypt

Method Details

__construct() public method

Construct a PBKDF2 hashing strategy with the given parameters
public __construct ( integer $cost )
$cost integer

hashPassword() public method

Creates a BCrypt hash
public hashPassword ( string $password, string $staticSalt = null ) : string
$password string The plaintext password to hash
$staticSalt string Optional static salt that will not be stored in the hashed password
return string the result of the crypt() call

validatePassword() public method

Passwords hashed with a different cost can be validated by using the cost parameter of the hashed password and salt.
public validatePassword ( string $password, string $hashedPasswordAndSalt, string $staticSalt = null ) : boolean
$password string The cleartext password
$hashedPasswordAndSalt string The derived key and salt in as returned by crypt() for verification
$staticSalt string Optional static salt that will be appended to the dynamic salt
return boolean TRUE if the given password matches the hashed password

Property Details

$cost protected_oe property

Number of rounds to use with BCrypt for hashing passwords, must be between 4 and 31
protected int $cost
return integer