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':
|
case 'SHA':
|
||||||
$hash = "{SHA}" . base64_encode(hex2bin(sha1($password)));
|
$hash = "{SHA}" . base64_encode(hex2bin(sha1($password)));
|
||||||
break;
|
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':
|
case 'PLAIN':
|
||||||
$hash = $password;
|
$hash = $password;
|
||||||
break;
|
break;
|
||||||
// use SSHA if the setting is invalid
|
case 'SSHA':
|
||||||
default:
|
default: // use SSHA if the setting is invalid
|
||||||
$salt0 = substr(pack("h*", md5($rand)), 0, 8);
|
$salt0 = substr(pack("h*", md5($rand)), 0, 8);
|
||||||
$salt = substr(pack("H*", sha1($salt0 . $password)), 0, 4);
|
$salt = substr(pack("H*", sha1($salt0 . $password)), 0, 4);
|
||||||
$hash = "{SSHA}" . base64_encode(hex2bin(sha1($password . $salt)) . $salt);
|
$hash = "{SSHA}" . base64_encode(hex2bin(sha1($password . $salt)) . $salt);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// enable/disable password
|
// enable/disable password
|
||||||
if (! $enabled) return pwd_disable($hash);
|
if (! $enabled) return pwd_disable($hash);
|
||||||
|
|
Loading…
Reference in New Issue