PHP 8.0.0 Beta 4 available for testing

password_algos

(PHP 7 >= 7.4.0)

password_algosGet available password hashing algorithm IDs

Descrierea

password_algos ( void ) : array

Returns a complete list of all registered password hashing algorithm IDs as an array of strings.

Parametri

Această funcție nu are parametri.

Valorile întoarse

Returns the available password hashing algorithm IDs.

Exemple

Example #1 Basic password() usage

<?php
print_r
(password_algos());
?>

Exemplul de mai sus va afișa ceva similar cu:

Array
(
    [0] => 2y
    [1] => argon2i
    [2] => argon2id
)
add a note add a note

User Contributed Notes 1 note

up
0
XRevan86
1 month ago
A polyfill for PHP 7.3 and older:
<?php
if (version_compare(PHP_VERSION, '7.4.0', '<')) {
    function
password_algos(): array
    {
       
$algos = [PASSWORD_BCRYPT];
       
defined('PASSWORD_ARGON2I')  && $algos[] = PASSWORD_ARGON2I;
       
defined('PASSWORD_ARGON2ID') && $algos[] = PASSWORD_ARGON2ID;
        return
$algos;
    }
}
?>
To Top