Documentation

Password
in package

Representation of a hashed password

Tags
copyright

Cloudrexx AG

author

Michael Ritter michael.ritter@comvation.com

subpackage

core_model

Table of Contents

Constants

HASH_ALGORITHM  = \PASSWORD_BCRYPT

Properties

$hashedPassword  : string

Methods

__construct()  : mixed
Initializes this Password instance
__toString()  : string
Casts this Password to a string
createFromPlaintext()  : Password
Creates a Password instance from a plaintext password (/not hashed)
matches()  : bool
Returns whether the given password matches this Password
checkPasswordValidity()  : void
Checks if the given string is valid as a password
hashPassword()  : string
Generate hash of password with default hash algorithm
updatePasswordHash()  : void
This updates the password in case is was hashed using the wrong algorithm

Constants

HASH_ALGORITHM

public int HASH_ALGORITHM = \PASSWORD_BCRYPT

Hash algorithm accepted by password_hash()

Properties

$hashedPassword

protected string $hashedPassword

This password's hash

Methods

__construct()

Initializes this Password instance

public __construct(string $hashedPassword) : mixed
Parameters
$hashedPassword : string

This password's hash

__toString()

Casts this Password to a string

public __toString() : string
Return values
string

Hashed password

createFromPlaintext()

Creates a Password instance from a plaintext password (/not hashed)

public static createFromPlaintext(string $plaintextPassword) : Password
Parameters
$plaintextPassword : string

A password in plain text

Tags
throws
ShinyException

If password does not meet requirements

Return values
Password

Password instance based on the given password

matches()

Returns whether the given password matches this Password

public matches(string $plaintextPassword) : bool
Parameters
$plaintextPassword : string

A password in plain text

Return values
bool

True if $plaintextPassword matches this Password, false otherwise

checkPasswordValidity()

Checks if the given string is valid as a password

protected static checkPasswordValidity(string $plaintextPassword) : void

This method returns nothing on success and throws an exception otherwise.

Parameters
$plaintextPassword : string

A password in plain text

Tags
throws
ShinyException

If password does not meet requirements

hashPassword()

Generate hash of password with default hash algorithm

protected static hashPassword(string $plaintextPassword[, bool $checkValidity = true ]) : string
Parameters
$plaintextPassword : string

A password in plain text

$checkValidity : bool = true

If set to false, password complexity is not validated

Tags
throws
ShinyException

In case the password hash generation fails

Return values
string

The generated hash of the supplied password

updatePasswordHash()

This updates the password in case is was hashed using the wrong algorithm

protected updatePasswordHash(string $plaintextPassword) : void

This method assumes, that the $plaintextPassword and $hashedPassword are checked to match each other.

Parameters
$plaintextPassword : string

A password in plain text


        
On this page

Search results