PHP password_get_info() Function

PHP 密码散列算法PHP Password Hashing Algorithm

The password_get_info() function is used to return information about the specified 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 with three elements:

  • algo: Constant matching the password algorithm.
  • algoName: Human-readable algorithm name.
  • options: Options provided when calling password_hash().

Example

Example

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

The output result is:

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

)

PHP 密码散列算法PHP Password Hashing Algorithm

Other Extensions