Overview

Namespaces

  • None
  • Wei
    • Validator

Classes

  • Apc
  • App
  • ArrayCache
  • Asset
  • Base
  • BaseCache
  • BaseController
  • Bicache
  • Cache
  • Config
  • Cookie
  • Couchbase
  • Counter
  • Db
  • DbCache
  • E
  • Env
  • Error
  • FileCache
  • Gravatar
  • Http
  • Lock
  • Logger
  • Memcache
  • Memcached
  • MongoCache
  • Password
  • PhpError
  • PhpFileCache
  • Pinyin
  • Record
  • Redis
  • Request
  • Response
  • Router
  • SafeUrl
  • Session
  • Soap
  • T
  • Ua
  • Upload
  • Url
  • Uuid
  • Validate
  • View
  • WeChatApp
  • Wei
  • Overview
  • Namespace
  • Class

Class Password

A wrapper class for password hashing functions

If you needs these original functions, please checkout https://github.com/ircmaxell/password_compat instead.

  • password_hash
  • password_get_info
  • password_needs_rehash
  • password_verify
Wei\Base
Extended by Wei\Password
Namespace: Wei
Author: Anthony Ferrara ircmaxell@php.net
Author: https://github.com/ircmaxell/password_compat/graphs/contributors
Author: Twin Huang twinhuang@qq.com
Link: https://github.com/ircmaxell/password_compat/blob/master/lib/password.php
Located at Password.php
Methods summary
public
# __construct( array $options = array() )

Constructor

Constructor

Parameters

$options

Throws

Exception

Overrides

Wei\Base::__construct()
public string|false
# hash( string $password, string $salt = null )

Hash the password using the specified algorithm

Hash the password using the specified algorithm

Parameters

$password
The password to hash
$salt
The salt string for the algorithm to use

Returns

string|false
The hashed password, or false on error.

Throws

InvalidArgumentException
public array
# getInfo( string $hash )

Get information about the password hash. Returns an array of the information that was used to generate the password hash.

Get information about the password hash. Returns an array of the information that was used to generate the password hash.

array( 'algo' => 1, 'algoName' => 'bcrypt', 'options' => array( 'cost' => 10, ), )

Parameters

$hash
The password hash to extract info from

Returns

array
The array of information about the hash.
public boolean
# needsRehash( string $hash, integer $algo, array $options = array() )

Determine if the password hash needs to be rehashed according to the options provided

Determine if the password hash needs to be rehashed according to the options provided

If the answer is true, after validating the password using password_verify, rehash it.

Parameters

$hash
The hash to test
$algo
The algorithm used for new password hashes
$options
The options array passed to password_hash

Returns

boolean
True if the password needs to be rehashed.
public boolean
# verify( string $password, string $hash )

Verify a password against a hash using a timing attack resistant approach

Verify a password against a hash using a timing attack resistant approach

Parameters

$password
The password to verify
$hash
The hash to verify against

Returns

boolean
If the password matches the hash
public
# setCost( integer $cost )

Set the cost parameter for bcrypt

Set the cost parameter for bcrypt

Parameters

$cost

Returns


$this

Throws

InvalidArgumentException
public string
# generateSalt( )

Generate a 22 bytes salt string

Generate a 22 bytes salt string

Returns

string
Methods inherited from Wei\Base
__call(), __get(), getOption(), setOption()
Properties summary
protected integer $cost

The cost parameter for bcrypt

The cost parameter for bcrypt

# 10
Properties inherited from Wei\Base
$providers, $wei
Wei Framework API documentation generated by ApiGen