Skip to content

Instantly share code, notes, and snippets.

@vrillusions
Created May 3, 2013 14:22
Show Gist options
  • Save vrillusions/5509401 to your computer and use it in GitHub Desktop.
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
<?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