Example 1 — Read the Algorithm and Cost
Inspect a stored bcrypt hash.
<?php
$hash = '$2y$07$BCryptRequires22Chrcte/VlQH0piJtjXl.0t1XkA8pw9dMXTpOq';
$info = password_get_info($hash);
echo "Algo: ", $info['algo'], PHP_EOL;
echo "Name: ", $info['algoName'], PHP_EOL;
echo "Cost: ", $info['options']['cost'], PHP_EOL; How It Works
- Start with a stored hash. This one is a bcrypt hash.
- Call the function. It returns an array.
- Read algo and algoName.
2yis the ID,bcryptis the name. - Read the cost. It lives inside the
optionsarray.

