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

PHP Basic Tutorial

PHP Advanced Tutorial

PHP & MySQL

PHP Reference Manual

PHP password_get_info() Function Usage and Example

PHP Password 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 Password Hashing Algorithm