code cleanup

This commit is contained in:
Roland Gruber 2008-02-25 20:54:11 +00:00
parent 185e7bf17a
commit 052c6bf39d
1 changed files with 3 additions and 8 deletions

View File

@ -197,20 +197,15 @@ function pwd_hash($password, $enabled = true, $hashType = 'SSHA') {
case 'SHA':
$hash = "{SHA}" . base64_encode(hex2bin(sha1($password)));
break;
case 'SSHA':
$salt0 = substr(pack("h*", md5($rand)), 0, 8);
$salt = substr(pack("H*", sha1($salt0 . $password)), 0, 4);
$hash = "{SSHA}" . base64_encode(hex2bin(sha1($password . $salt)) . $salt);
break;
case 'PLAIN':
$hash = $password;
break;
// use SSHA if the setting is invalid
default:
case 'SSHA':
default: // use SSHA if the setting is invalid
$salt0 = substr(pack("h*", md5($rand)), 0, 8);
$salt = substr(pack("H*", sha1($salt0 . $password)), 0, 4);
$hash = "{SSHA}" . base64_encode(hex2bin(sha1($password . $salt)) . $salt);
break;
break;
}
// enable/disable password
if (! $enabled) return pwd_disable($hash);