English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Basic PHP Tutorial

Advanced PHP Tutorial

PHP & MySQL

PHP Reference Manual

Usage and examples of PHP password_get_info() function

PHP Hashing Algorithm

The password_get_info() function is used to return information about the specified hash (hash).

PHP version requirement: PHP 5 => 5.5.0, PHP 7

Syntax

array password_get_info(string $hash)

Parameter description:

Return value

Returns an associative array of three elements:

  • algo: Constant matching the password algorithm.

  • algoName: Human-readable algorithm name.

  • options: Options provided when calling password_hash().

Online Example

<?php
// Password
$password_plaintext = "12345";
 
// Create a hash value using password_hash()
$password_hash = password_hash($password_plaintext, PASSWORD_DEFAULT, ['cost' => 11 );
 
// View information
print_r(password_get_info($password_hash));

The output is:

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

PHP Hashing Algorithm