Class PasswordHashing
License: GNU General Public License v2.0 only **********************************************************************************************
Class:
PasswordHashing
This class provides static functions for different tasks for passwords and hashing It used the "password_compat" lib to provide forward compatibility with the password_* functions that ship with PHP 5.5 It used the "random_compat" lib to provide forward compatibility with the random_* functions that ship with PHP 7.0 It used the "phpass" lib to provide backward compatibility to the old password hashing way
Functions: hash() hash the given password with the given options verify() verify if the given password belongs to the given hash needsRehash() checks if the given hash is generated from the given options genRandomPassword() generate a cryptographically strong random password genRandomInt() generate a cryptographically strong random int passwordInfo() provides infos about the given password (length, number, lowerCase, upperCase, symbol) hashInfo() provides infos about the given hash (Algorithm & Options, PRIVATE/PORTABLE_HASH, MD5, UNKNOWN) costBenchmark() run a benchmark to get the best fitting cost value
Located at passwordhashing.php
Methods summary
public static
string|false
|
|
public static
boolean
|
|
public static
boolean
|
#
needsRehash( string $hash, string $algorithm = 'DEFAULT', array $options = array() )
Checks if the given hash is generated from the given options. The default algorithm uses the password_* methods, otherwise the builtin helper for SHA-512 crypt hashes from the operating system. |
public static
string
|
#
genRandomPassword( integer $length = 12, string $charset = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' )
Generate a cryptographically strong random password |
public static
integer
|
|
public static
array<string,int|bool>
|
#
passwordInfo( string $password )
Provides infos about the given password (length, number, lowerCase, upperCase, symbol) |
public static
array|string
|
|
public static
array
|
#
costBenchmark( float $maxTime = 0.5, string $password = 'password', string $algorithm = 'DEFAULT', array $options = array('cost' => 12) )
Run a benchmark to get the best fitting cost value. The cost value can vary from 4 to 31. |