Here's an example function that utilizes the password_hash() function to hash and salt a password:
main.php351 chars11 linesTo use the function, simply pass in the user's password:
main.php180 chars8 lines
This function generates a random salt using mcrypt_create_iv() function, then concatenates the salt with the user's password, and finally hashes the combined string using the password_hash() function with the BCRYPT algorithm. The resulting hashed password includes the salt, so you can store it directly in the database.
gistlibby LogSnag