总有人间一两风,填我十万八千梦

PHP password_algos 用法 手册 | 示例代码

PHP开发手册 归档 154℃ 0评论

password_algos

(PHP 7 >= 7.4.0, PHP 8)

password_algosGet available password hashing algorithm IDs

说明

password_algos(): array

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

参数

此函数没有参数。

返回值

Returns the available password hashing algorithm IDs.

范例

示例 #1 Basic password() usage

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

以上例程的输出类似于:

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

用户贡献的笔记

XRevan86

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;
    }
}
?>

转载请注明:悠然品鉴 » PHP password_algos 用法 手册 | 示例代码

喜欢 (0)or分享 (0)
发表我的评论
取消评论

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址