Thursday, September 4, 2025
HomeLanguagesPHP password_get_info() Function

PHP password_get_info() Function

The password_get_info() is an inbuilt PHP function where detailed information regarding the given hash will be returned.

Syntax:

password_get_info(string $hash): array

Parameter: This function accepts a single parameter:

  • hash: This parameter defines the hash of the password by creating the password_hash() function.

 

Return Values:

  • algo: This parameter define which type of password algorithm is used in the password.
  • algoName: This parameter defines the name of the algorithm in human-readable form.
  • options: This parameter includes the options provided when calling the password_hash() function.

Example 1: The following code demonstrates the password_get_info() function.

PHP




<?php 
   $a= password_hash("neveropen", PASSWORD_DEFAULT);
   var_dump(password_get_info($a));
?>


Output:

array(3) {
     ["algo"]=> string(2) "2y"
     ["algoName"]=> string(6) "bcrypt"
     ["options"]=> array(1) {
                     ["cost"]=> int(10)
             }
}

Example 2: The following code demonstrates the password_get_info() function.

PHP




<?php 
   $password = "neveropen";
   $hashedPassword
         password_hash($password, PASSWORD_DEFAULT);
     
   // Retrieve password information
   $passwordInfo
         password_get_info($hashedPassword);
      
   // Display password information
   echo "Hash algorithm: " . $passwordInfo['algo'] . "\n";
   echo "Hash strength: " . $passwordInfo['algoName'] . "\n";
?>


Output:

Hash algorithm: 2y
Hash strength: bcrypt

Reference: https://www.php.net/manual/en/function.password-get-info.php

Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!
RELATED ARTICLES

Most Popular

Dominic
32261 POSTS0 COMMENTS
Milvus
81 POSTS0 COMMENTS
Nango Kala
6626 POSTS0 COMMENTS
Nicole Veronica
11795 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11855 POSTS0 COMMENTS
Shaida Kate Naidoo
6747 POSTS0 COMMENTS
Ted Musemwa
7023 POSTS0 COMMENTS
Thapelo Manthata
6695 POSTS0 COMMENTS
Umr Jansen
6714 POSTS0 COMMENTS