$salt, 'password_hashed' => custom_password_hash($salt . $password), )); } /** * utility function to generate random strings */ function generate_random_salt($length = 32, $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890') { // Length of character list $rand_max = strlen($chars) - 1; // Start our string $salt = $chars{rand(0, $chars_length)}; // Generate random string for ($i = 1; $i < $length; $i = strlen($salt)) { // Grab a random character from our list $r = $chars{mt_rand(0, $rand_max)}; // Make sure the same two characters don't appear next to each other if ($r != $salt{$i - 1}) { $salt .= $r; } } return $salt; } /** * this can be defined in sites/%/settings.php */ function custom_password_hash($unhashed, $hash_function = NULL) { static $system_salt = 'l0ajcpoaioaöjp897zvqn7'; switch ($hash_function) { // case 'myhashfunction': // ... (implement your own hashing) default: // TODO: add key strengthening with blowfish, if available. return sha256($unhashed . $system_salt); } }