Password
in package
Class Password.
Table of Contents
- LIMIT_INTERACTIVE = 0
- Used to set operations or memory limit as interactive.
- LIMIT_MODERATE = 1
- Used to set operations or memory limit as moderate.
- LIMIT_SENSITIVE = 2
- Used to set operations or memory limit as sensitive.
- $memLimit : int
- $opsLimit : int
- getMemLimit() : int
- Gets the default Password memory limit constant value.
- getOpsLimit() : int
- Gets the default Password operations limit constant value.
- hash() : string
- Makes a password hash.
- needsRehash() : bool
- Checks if a hash needs to be rehashed based on the ops and mem limits.
- setMemLimit() : void
- Sets the default Password memory limit.
- setOpsLimit() : void
- Sets the default Password operations limit.
- verify() : bool
- Verifies a password against a hash.
- getSodiumMemLimit() : int
- Gets an appropriate sodium memory limit value from a Password constant.
- getSodiumOpsLimit() : int
- Gets an appropriate sodium operations limit value from a Password constant.
Constants
LIMIT_INTERACTIVE
Used to set operations or memory limit as interactive.
public
int
LIMIT_INTERACTIVE
= 0
It enables the use of 2 CPU operations or 64 MB RAM.
LIMIT_MODERATE
Used to set operations or memory limit as moderate.
public
int
LIMIT_MODERATE
= 1
It enables the use of 3 CPU operations or 256 MB RAM.
LIMIT_SENSITIVE
Used to set operations or memory limit as sensitive.
public
int
LIMIT_SENSITIVE
= 2
It enables the use of 4 CPU operations or 1 GB RAM.
Properties
$memLimit
protected
static int
$memLimit
= \Framework\Crypto\Password::LIMIT_INTERACTIVE
$opsLimit
protected
static int
$opsLimit
= \Framework\Crypto\Password::LIMIT_INTERACTIVE
Methods
getMemLimit()
Gets the default Password memory limit constant value.
public
static getMemLimit() : int
Return values
int —getOpsLimit()
Gets the default Password operations limit constant value.
public
static getOpsLimit() : int
Return values
int —hash()
Makes a password hash.
public
static hash(string $password[, int|null $opslimit = null ][, int|null $memlimit = null ]) : string
Parameters
- $password : string
- $opslimit : int|null = null
-
A Password constant or null to use the default set for opslimit
- $memlimit : int|null = null
-
A Password constant or null to use the default set for memlimit. Typically, it should be paired with the opslimit value
Tags
Return values
string —needsRehash()
Checks if a hash needs to be rehashed based on the ops and mem limits.
public
static needsRehash(string $hash[, int|null $opslimit = null ][, int|null $memlimit = null ]) : bool
Parameters
- $hash : string
- $opslimit : int|null = null
-
A Password constant or null to use the default set for opslimit
- $memlimit : int|null = null
-
A Password constant or null to use the default set for memlimit
Return values
bool —setMemLimit()
Sets the default Password memory limit.
public
static setMemLimit(int $memLimit) : void
Parameters
- $memLimit : int
-
A Password constant value. Typically, it should be paired with the opslimit value
Tags
Return values
void —setOpsLimit()
Sets the default Password operations limit.
public
static setOpsLimit(int $opsLimit) : void
Parameters
- $opsLimit : int
-
A Password constant value
Tags
Return values
void —verify()
Verifies a password against a hash.
public
static verify(string $password, string $hash) : bool
Parameters
- $password : string
- $hash : string
Tags
Return values
bool —getSodiumMemLimit()
Gets an appropriate sodium memory limit value from a Password constant.
protected
static getSodiumMemLimit(int $constant) : int
Parameters
- $constant : int
Tags
Return values
int —getSodiumOpsLimit()
Gets an appropriate sodium operations limit value from a Password constant.
protected
static getSodiumOpsLimit(int $constant) : int
Parameters
- $constant : int