Skip to content

Instantly share code, notes, and snippets.

@feeela
feeela / function.passwordHash.php
Created November 7, 2013 14:33
passwordHash() – generate salted passwords Simple password hashing function without recursion using a salt, that is stored together with the password.
/**
* Generate salted password, using new salt or exiting one from the password itself.
*
* @param string $plainTextPassword
* @param string $salt default = NULL (create new salt)
* @param int $saltLength default = 9 (the salt is the first X chars of the password hash)
* @return string password-hash
*/
function passwordHash( $plainTextPassword, $salt = null, $saltLength = 9 )
{