Thursday, July 4, 2024
HomeLanguagesPhpPHP password_algos() Function

PHP password_algos() Function

The password_algos() is an inbuilt function in PHP that returns the Ids which get available by the password hashing algorithm. Here, Id represents the array of strings.

Syntax:

password_algos(): array

Parameter: This function does not accept any parameter.

Return Value: This function returns an array containing the names of all supported password hashing algorithms. The array elements are strings representing the names of the hashing algorithms, such as bcrypt, argon2i, argon2id, sha256, and sha512, among others.

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

PHP




<?php
$algos = password_algos();
      
echo "Supported password hashing algorithms:\n";
foreach ($algos as $algo) {
    echo "- $algo\n";
}  
?>


Output:

Supported password hashing algorithms:
- 2y
- argon2i
- argon2id

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

PHP




<?php
$algo = 'argon2i';
if (in_array($algo, password_algos())) {
    echo "The $algo algorithm is supported.\n";
else {
    echo "The $algo algorithm is not supported.\n";
}
?>


Output:

The argon2i algorithm is supported. 

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

Nicole Veronica Rubhabha
Nicole Veronica Rubhabha
A highly competent and organized individual DotNet developer with a track record of architecting and developing web client-server applications. Recognized as a personable, dedicated performer who demonstrates innovation, communication, and teamwork to ensure quality and timely project completion. Expertise in C#, ASP.Net, MVC, LINQ, EF 6, Web Services, SQL Server, MySql, Web development,
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments