code cleanup
This commit is contained in:
parent
185e7bf17a
commit
052c6bf39d
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue