PHP Function Reference

PHP password_get_info() Function



The PHP password_get_info() function returns an array of information about the given hash created by an algorithm supported by password_hash().

Syntax

password_get_info(hash)

Parameters

hash Required. Specify a hash created by password_hash().

Return Value

Returns an associative array with three elements:

Example: password_get_info() example

The example below shows the usage of password_get_info() function.

<?php
//hashing the password using the current DEFAULT 
//algorithm which is presently BCRYPT, and 
//produces a 60 character result. Note that DEFAULT 
//may change over time, therefore allow storage 
//to expand past 60 characters (255 recommended)
$hash = password_hash("myPassword", PASSWORD_DEFAULT);

//displaying the hash
echo $hash;

echo "\n";
//getting the information about the $hash 
print_r(password_get_info($hash));
?>

The output of the above code will be:

$2y$10$.SCsHZ4KA04AFwoRj6XOS.6iKtQzsO.ydxo6gOVbauASPEoV6cm4a
Array
(
    [algo] => 2y
    [algoName] => bcrypt
    [options] => Array
        (
            [cost] => 10
        )

)

❮ PHP Password Hashing Reference