MessageDigestPasswordHasher
in package
implements
LegacyPasswordHasherInterface
Uses
CheckPasswordLengthTrait
MessageDigestPasswordHasher uses a message digest algorithm.
Tags
Table of Contents
Interfaces
- LegacyPasswordHasherInterface
- Provides password hashing and verification capabilities for "legacy" hashers that require external salts.
Properties
- $algorithm : string
- $encodeHashAsBase64 : bool
- $hashLength : int
- $iterations : int
Methods
- __construct() : mixed
- hash() : string
- Hashes a plain password.
- needsRehash() : bool
- verify() : bool
- Checks that a plain password and a salt match a password hash.
- isPasswordTooLong() : bool
- mergePasswordAndSalt() : string
Properties
$algorithm
private
string
$algorithm
$encodeHashAsBase64
private
bool
$encodeHashAsBase64
$hashLength
private
int
$hashLength
= -1
$iterations
private
int
$iterations
= 1
Methods
__construct()
public
__construct([string $algorithm = 'sha512' ][, bool $encodeHashAsBase64 = true ][, int $iterations = 5000 ]) : mixed
Parameters
- $algorithm : string = 'sha512'
-
The digest algorithm to use
- $encodeHashAsBase64 : bool = true
-
Whether to base64 encode the password hash
- $iterations : int = 5000
-
The number of iterations to use to stretch the password hash
hash()
Hashes a plain password.
public
hash(string $plainPassword[, string $salt = null ]) : string
Parameters
- $plainPassword : string
- $salt : string = null
Return values
stringneedsRehash()
public
needsRehash(string $hashedPassword) : bool
Parameters
- $hashedPassword : string
Return values
boolverify()
Checks that a plain password and a salt match a password hash.
public
verify(string $hashedPassword, string $plainPassword[, string $salt = null ]) : bool
Parameters
- $hashedPassword : string
- $plainPassword : string
- $salt : string = null
Return values
boolisPasswordTooLong()
private
isPasswordTooLong(string $password) : bool
Parameters
- $password : string
Return values
boolmergePasswordAndSalt()
private
mergePasswordAndSalt(string $password, string|null $salt) : string
Parameters
- $password : string
- $salt : string|null