phpDocumentor

PasswordHashStrategy implements AuthStrategyInterface

Class PasswordHashStrategy

Tags
category

System

subpackage

Strategies

Interfaces, Classes and Traits

AuthStrategyInterface
Interface AuthStrategyInterface

Table of Contents

getHash()  : string
Generates a hash by given password string.
getRehashedPassword()  : string
Returns a rehashed password hash if it does not match the currently used hashing algorithm.
verify()  : bool
Verifies a given password by its stored hash from the current hashing algorithm.

Methods

getHash()

Generates a hash by given password string.

public getHash(StringType $password) : string
Parameters
$password : StringType

String that should be hashed.

Tags
throws
RuntimeException

if password_hash() could not create a hash.

Return values
string

Resulting hash.

getRehashedPassword()

Returns a rehashed password hash if it does not match the currently used hashing algorithm.

public getRehashedPassword(StringType $password, NonEmptyStringType $hash[, AuthStrategyCollection|null $alternativeAlgorithmCollection = null ]) : string
Parameters
$password : StringType

Password that should be rehashed by a new algorithm.

$hash : NonEmptyStringType

Current password hash.

$alternativeAlgorithmCollection : AuthStrategyCollection|null = null

Collection of alternative hashing algorithms.

Return values
string

The new password hash.

verify()

Verifies a given password by its stored hash from the current hashing algorithm.

public verify(StringType $password, NonEmptyStringType $hash[, AuthStrategyCollection $alternativeAlgorithmCollection = null ]) : bool
Parameters
$password : StringType

Password that should be verified.

$hash : NonEmptyStringType

Stored Hash of a password.

$alternativeAlgorithmCollection : AuthStrategyCollection = null

Collection of alternative hashing algorithms.

Return values
bool

Returns true if $password matches $hash, false otherwise.

Search results