Sunday, September 22, 2024
Google search engine
HomeLanguagesPHP 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

Dominic Rubhabha-Wardslaus
Dominic Rubhabha-Wardslaushttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Recent Comments