mirror of
https://github.com/pi-hole/web.git
synced 2026-04-24 02:39:25 +01:00
Use hash_equals in password.php (and move it to funcs.php)
Signed-off-by: Mcat12 <newtoncat12@yahoo.com>
This commit is contained in:
@@ -25,4 +25,24 @@ function checkfile($filename) {
|
||||
}
|
||||
}
|
||||
|
||||
// Credit: http://php.net/manual/en/function.hash-equals.php#119576
|
||||
if(!function_exists('hash_equals')) {
|
||||
function hash_equals($known_string, $user_string) {
|
||||
$ret = 0;
|
||||
|
||||
if (strlen($known_string) !== strlen($user_string)) {
|
||||
$user_string = $known_string;
|
||||
$ret = 1;
|
||||
}
|
||||
|
||||
$res = $known_string ^ $user_string;
|
||||
|
||||
for ($i = strlen($res) - 1; $i >= 0; --$i) {
|
||||
$ret |= ord($res[$i]);
|
||||
}
|
||||
|
||||
return !$ret;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user