From 5f2b708377aec4bc5f1d731dfbb50557552d0482 Mon Sep 17 00:00:00 2001 From: Romain d'Alverny Date: Tue, 11 Jan 2022 12:26:15 +0100 Subject: Remove unneeded polyfills --- app/classes/Planet.php | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-) (limited to 'app/classes') diff --git a/app/classes/Planet.php b/app/classes/Planet.php index 5c6d7cf..d6007e5 100644 --- a/app/classes/Planet.php +++ b/app/classes/Planet.php @@ -75,29 +75,9 @@ class Planet * @param string $supplied * @return bool */ - public static function authenticateUser($known = '', $supplied = '') + public static function authenticateUser(string $known = '', string $supplied = '') { - // The hash_equals function was introduced in PHP 5.6.0. If it's not - // existing in the current context (PHP version too old), and to ensure - // compatibility with those old interpreters, we'll have to provide - // an PHP implementation of this function. - if (function_exists('hash_equals')) { - return hash_equals($known, $supplied); - } - - // Some implementation references can be found on the function comment. - $knownLen = mb_strlen($known); - if ($knownLen !== mb_strlen($supplied)) { - return false; - } - - // Ensure that all the characters are the same, and continue until the - // end of the string even if an difference was found. - for ($i = 0, $comparison = 0; $i < $knownLen; $i++) { - $comparison |= ord($known[$i]) ^ ord($supplied[$i]); - } - - return ($comparison === 0); + return hash_equals($known, $supplied); } /** -- cgit v1.2.1