A class to hash and verify passwords using verious methods

category OSS
package OSS_Auth
copyright Copyright (c) 2007 - 2012, Open Source Solutions Limited, Dublin, Ireland
license New BSD License

 Methods

A generic password hashing method using a given configuration array

hash(string $pw, array $config) : string
Static

The parameters expected in $config are:

  • pwhash - a hashing method from the HASH_ constants in this class
  • hash_cost - a cost parameter for certain hashing functions - e.g. bcrypt (defaults to 9)

Parameters

$pw

string

The plaintext password to hash

$config

array

The resources.auth.oss array from application.ini

Exceptions

\OSS_Exception

Returns

stringThe hashed password

A generic password verification function for various hashing methods using a given configuration array

verify(string $pwplain, string $pwhash, array $config) : bool
Static
see \global\hash()

Parameters

$pwplain

string

The plaintext password

$pwhash

string

The hashed password to use for verification

$config

array

The resources.auth.oss array from application.ini

Exceptions

\OSS_Exception

Returns

boolTrue if the passwords match

 Constants

 

HASH_BCRYPT

HASH_BCRYPT 
 

HASH_PLAIN

HASH_PLAIN 
 

HASH_PLAINTEXT

HASH_PLAINTEXT 
 

HASH_UNKNOWN

HASH_UNKNOWN