PasswordHashStrategy

Implements \AuthStrategyInterface

Class PasswordHashStrategy

category

System

package

Authentication

subpackage

Strategies

Methods

Generates a hash by given password string.

getHash(\StringType $password) : string
Throws
\RuntimeException

if password_hash() could not create a hash.

Arguments

$password

\StringType

String that should be hashed.

Response

string

Resulting hash.

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

getRehashedPassword(\StringType $password, \NonEmptyStringType $hash, \AuthStrategyCollection|null $alternativeAlgorithmCollection = null) : string

Arguments

$password

\StringType

Password that should be rehashed by a new algorithm.

$hash

\NonEmptyStringType

Current password hash.

$alternativeAlgorithmCollection

\AuthStrategyCollection|null

Collection of alternative hashing algorithms.

Response

string

The new password hash.

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

verify(\StringType $password, \NonEmptyStringType $hash, \AuthStrategyCollection $alternativeAlgorithmCollection = null) : boolean

Arguments

$password

\StringType

Password that should be verified.

$hash

\NonEmptyStringType

Stored Hash of a password.

$alternativeAlgorithmCollection

\AuthStrategyCollection

Collection of alternative hashing algorithms.

Response

boolean

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