PHP password_get_info() 函数

PHP 教程 · 2019-01-31 22:56:39

password_get_info() 函数用于返回指定散列(hash)的相关信息。

PHP 版本要求: PHP 5 >= 5.5.0, PHP 7

语法

array password_get_info ( string $hash )

参数说明:

  • $hash: 一个由 password_hash() 创建的散列值。

返回值

返回三个元素的关联数组:

  • algo: 匹配密码算法的常量。
  • algoName: 人类可读的算法名称。
  • options: 调用 password_hash() 时提供的选项。

实例

实例

<?php // 密码 $password_plaintext = "12345"; // 使用 password_hash() 创建散列值 $password_hash = password_hash( $password_plaintext, PASSWORD_DEFAULT, [ 'cost' => 11 ] ); // 查看信息 print_r( password_get_info( $password_hash ) );

输出结果为:

Array
(
    [algo] => 1
    [algoName] => bcrypt
    [options] => Array
        (
            [cost] => 11
        )

)

点击查看所有 PHP 教程 文章: https://www.codercto.com/courses/l/5.html

查看所有标签

Distributed Systems

Distributed Systems

Sukumar Ghosh / Chapman and Hall/CRC / 2014-7-14 / USD 119.95

Distributed Systems: An Algorithmic Approach, Second Edition provides a balanced and straightforward treatment of the underlying theory and practical applications of distributed computing. As in the p......一起来看看 《Distributed Systems》 这本书的介绍吧!

HTML 压缩/解压工具
HTML 压缩/解压工具

在线压缩/解压 HTML 代码

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器

RGB CMYK 转换工具
RGB CMYK 转换工具

RGB CMYK 互转工具