Created
May 3, 2013 14:22
-
-
Save vrillusions/5509401 to your computer and use it in GitHub Desktop.
Sample function that creates an SSHA has for ldap - haven't fully tested
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function hash_password($password) { | |
if (@is_readable('/dev/urandom')) { | |
$f=fopen('/dev/urandom', 'rb'); | |
$salt=fread($f, 4); | |
fclose($f); | |
} else { | |
die('Could not query /dev/urandom'); | |
} | |
return '{SSHA}' . base64_encode(sha1( $password.$salt, TRUE ). $salt); | |
} | |
echo hash_password('test123').PHP_EOL; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment