PHP - hash_pbkdf2 function

hash, password-protection, php, security

Solution

EDIT: As of `PHP 5.5.0` this function is now bundled into the core library.

This function is not (yet anyway) available in core PHP. It was proposed not that long ago and so far you can only get it as a patch.

You can use `crypt` or `hash` instead. `crypt` is actually suggested in `hash_pbkdf2` documentation:

Caution The PBKDF2 method can be used for hashing passwords for storage (it is NIST approved for that use). However, it should be noted that `CRYPT_BLOWFISH` is better suited for password storage and should be used instead via `crypt()`.

Problem

I'm trying to do a function to hash passwords with this php function: http://be.php.net/manual/en/function.hash-pbkdf2.php. Here is the code: ``` $hash_algo = "sha256"; $password = "password"; $salt = "salt"; $iterations = 1; $length = 1; $raw_output = false; $hash = hash_pbkdf2($hash_algo, $password, $salt, $iterations ,$length ,$raw_output); echo $hash; ``` I got this error: Fatal error: Call to undefined function hash_pbkdf2(). How can the function be undefined??? PS: All the values of my variables are set just for testing the function. Obviously the salt will not be "salt", etc.

Original source