Hasher
Password hashing and validation class.
Tags
Table of Contents
$defaultRounds | Default crypt cost factor. | int |
---|---|---|
getHashType() | Returns the hashing type for a specified password hash. | string |
hash() | Hashes a plaintext password using bcrypt. | string |
verify() | Verify a plaintext password against the user's hashed password. | bool |
cost() | Extract the cost value from the options array. | int |
Properties
$defaultRounds
Default crypt cost factor.
protected
int
$defaultRounds
= 10
Methods
getHashType()
Returns the hashing type for a specified password hash.
public
getHashType(
$password :
string
)
: string
Automatically detects the hash type: "sha1" (for UserCake legacy accounts), "legacy" (for 0.1.x accounts), and "modern" (used for new accounts).
Parameters
- $password : string
the hashed password.
Return values
string —"sha1"|"legacy"|"modern".
hash()
Hashes a plaintext password using bcrypt.
public
hash(
$password :
string
[, $options :
array
= [] ]
)
: string
Parameters
- $password : string
the plaintext password.
- $options : array = []
Tags
Return values
string —the hashed password.
verify()
Verify a plaintext password against the user's hashed password.
public
verify(
$password :
string
, $hash :
string
[, $options :
array
= [] ]
)
: bool
Parameters
- $password : string
The plaintext password to verify.
- $hash : string
The hash to compare against.
- $options : array = []
Return values
bool —True if the password matches, false otherwise.
cost()
Extract the cost value from the options array.
protected
cost(
[ $options :
array
= [] ]
)
: int
Parameters
- $options : array = []