password_algos

(PHP 7 >= 7.4.0, PHP 8)

password_algosGet available password hashing algorithm IDs

Descrição

password_algos ( ) : array

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

Parâmetros

Esta função não possui parâmetros.

Valor Retornado

Returns the available password hashing algorithm IDs.

Exemplos

Exemplo #1 Basic password() usage

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

O exemplo acima irá imprimir algo similar à:

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

User Contributed Notes 1 note

up
1
XRevan86
8 months 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