PHP | hash_pbkdf2() Function Last Updated : 11 Jul, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report The hash_pbkdf2() function is an inbuilt function in PHP which is used to generate a PBKDF2 key derivation of a supplied password. Syntax: string hash_pbkdf2( $algo, $pass, $salt, $itr, $len, $raw_opt ) Parameters: This function accept six parameters as mention above and describe below. $algo: It is the required parameter which specifies the selected hashing algorithm (like- "md5", "sha256", "sha1"). $pass: This parameter is used to specify the password to use for the derivation. $salt: This parameter is used for the derivation and the value should be generated randomly. $itr: This parameter count the number of internal iterations. $len: This parameter is used to hold the length of the output string. $raw_opt: If this parameter set to True then its output will be raw binary data and if this parameter set to false then output will be lowercase hexits. Return Value: This function returns the string containing the calculated message digest as lowercase hexits. Below programs illustrate the hash_pbkdf2() function in PHP: Program 1: php <?php $gfg = "GeeksforGeeks"; $iterations = 142; // Generate a random IV using // openssl_random_pseudo_bytes() // random_bytes() or another // suitable source of randomness. $salt = openssl_random_pseudo_bytes(16); // Using hash_pbkdf2 function $hash = hash_pbkdf2("md5", $gfg, $salt, $iterations, 30); // Display result echo $hash; ?> Output: f0ebbbf59869d76f946c4b15340761 Program 2: php <?php $gfg = "Contribute1234"; $iterations = 100; // Generate a random IV using // openssl_random_pseudo_bytes() // random_bytes() or another // suitable source of randomness. $salt = openssl_random_pseudo_bytes(8); // Using hash_pbkdf2 function $hash = hash_pbkdf2("md5", $gfg, $salt, $iterations, 20, false); // Display result echo $hash; ?> Output: 715b385158045923923c Reference: https://www.php.net/manual/en/function.hash-pbkdf2.php Comment More infoAdvertise with us Next Article PHP | hash_hmac() Function R R_Raj Follow Improve Article Tags : Web Technologies PHP PHP-function Similar Reads PHP openssl_pbkdf2() Function The openssl_pbkdf2() function is an inbuilt function in PHP that implements the Password-Based Key Derivation Function 2 (PBKDF2) algorithm provided by the OpenSSL library. The algorithm is designed to be slow and computationally intensive, making it resistant to brute-force attacks. Syntax: openssl 2 min read PHP | hash_hmac() Function The hash_hmac() function is an inbuilt function in PHP which is used to generate the keyed hash value using the HMAC method. Syntax: string hash_hmac( $algo, $msg, $key, $raw_opt ) Parameters: This function accepts four parameters as mention above and describe below. $algo: It is the required parame 2 min read PHP | hash_file( ) Function The hash_file() function is an inbuilt function in PHP which is used to generate a hash value using the contents of a given file. Syntax: string hash_file( $algo, $file, $raw_opt ) Parameters: This function accept three parameters as mention above and describe below. $algo: It is the required parame 2 min read PHP | hash_copy() Function The hash_copy() function is an inbuilt function in PHP which is used to get the copy of hashing context. Syntax: hash_copy( $context ) Parameters: This function accepts single parameter $context which is used to specify the hashing context returned by hash_init() function. Return Value: This functio 1 min read PHP | hash_final() Function The hash_final() function is an inbuilt function in PHP which is used to finalize an incremental hash and return the resulting digest. Syntax: hash_final( $context, $raw_output ) Parameters: This function accept two parameters as mention above and describe below. $context: This parameter is used to 1 min read PHP | hash_algos() Function The hash_algos() function is an inbuilt function in PHP which is used to return a list of registered hashing algorithms. Syntax: array hash_algos( void ) Parameter: This function does not accepts any parameter. Return Value: This function returns a numerically indexed array which contains the list o 2 min read Like