NativePasswordHasher
in package
implements
PasswordHasherInterface
Uses
CheckPasswordLengthTrait
FinalYes
Hashes passwords using password_hash().
Tags
Table of Contents
Interfaces
- PasswordHasherInterface
- Provides password hashing capabilities.
Properties
- $algorithm : string
- $options : array<string|int, mixed>
Methods
- __construct() : mixed
- hash() : string
- Hashes a plain password.
- needsRehash() : bool
- Checks if a password hash would benefit from rehashing.
- verify() : bool
- Verifies a plain password against a hash.
- isPasswordTooLong() : bool
Properties
$algorithm
private
string
$algorithm
= \PASSWORD_BCRYPT
$options
private
array<string|int, mixed>
$options
Methods
__construct()
public
__construct([int $opsLimit = null ][, int $memLimit = null ][, int $cost = null ][, string|null $algorithm = null ]) : mixed
Parameters
- $opsLimit : int = null
- $memLimit : int = null
- $cost : int = null
- $algorithm : string|null = null
-
An algorithm supported by password_hash() or null to use the best available algorithm
hash()
Hashes a plain password.
public
hash(string $plainPassword) : string
Parameters
- $plainPassword : string
Return values
stringneedsRehash()
Checks if a password hash would benefit from rehashing.
public
needsRehash(string $hashedPassword) : bool
Parameters
- $hashedPassword : string
Return values
boolverify()
Verifies a plain password against a hash.
public
verify(string $hashedPassword, string $plainPassword) : bool
Parameters
- $hashedPassword : string
- $plainPassword : string
Return values
boolisPasswordTooLong()
private
isPasswordTooLong(string $password) : bool
Parameters
- $password : string