PHP Class Dcrypt\Hash

16 bytes => iv 12 bytes => cost checksum 4 bytes => cost 32 bytes => hmac ivivivivivivivivsssssssssssscosthmachmachmachmachmachmachmachmac
Inheritance: extends Support
ファイルを表示 Open project: dopecode/dcrypt Class Usage Examples

Public Methods

Method Description
ihmac ( string $data, string $key, integer $iter, string $algo = 'sha256' ) : string Perform a raw iterative HMAC operation with a configurable algo.
make ( string $input, string $password, integer $cost = 250000 ) : string Hash an input string into a salted 512 byte hash.
verify ( string $input, string $hash, string $password ) : boolean Check the validity of a hash.

Private Methods

Method Description
build ( string $input, string $password, integer $cost, string | null $salt = null ) : string Internal function used to build the actual hash.
cost ( integer $cost ) : integer Return a normalized cost value.
costHash ( $cost, $salt, $password )

Method Details

ihmac() public static method

This class always performs at least one hash to prevent the input from being passed back unchanged if bad parameters are set.
public static ihmac ( string $data, string $key, integer $iter, string $algo = 'sha256' ) : string
$data string Data to hash.
$key string Key to use to authenticate the hash.
$iter integer Number of times to iteratate the hash
$algo string Name of algo (sha256 or sha512 recommended)
return string

make() public static method

Hash an input string into a salted 512 byte hash.
public static make ( string $input, string $password, integer $cost = 250000 ) : string
$input string Data to hash.
$password string HMAC validation password.
$cost integer Cost value of the hash.
return string

verify() public static method

Check the validity of a hash.
public static verify ( string $input, string $hash, string $password ) : boolean
$input string Input to test.
$hash string Known hash to validate against.
$password string HMAC password to use during iterative hash.
return boolean