8000 use core StringUtils to compare hashes · symfony/symfony@9fc01d2 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9fc01d2

Browse files
committed
use core StringUtils to compare hashes
1 parent 79baf8d commit 9fc01d2

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

src/Symfony/Component/Security/Http/RememberMe/TokenBasedRememberMeServices.php

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
1818
use Symfony\Component\Security\Core\Exception\AuthenticationException;
1919
use Symfony\Component\Security\Core\User\UserInterface;
20+
use Symfony\Component\Security\Core\Util\StringUtils;
2021

2122
/**
2223
* Concrete implementation of the RememberMeServicesInterface providing
@@ -77,16 +78,7 @@ protected function processAutoLoginCookie(array $cookieParts, Request $request)
7778
*/
7879
private function compareHashes($hash1, $hash2)
7980
{
80-
if (strlen($hash1) !== $c = strlen($hash2)) {
81-
return false;
82-
}
83-
84-
$result = 0;
85-
for ($i = 0; $i < $c; $i++) {
86-
$result |= ord($hash1[$i]) ^ ord($hash2[$i]);
87-
}
88-
89-
return 0 === $result;
81+
return StringUtils::equals($hash1, $hash2);
9082
}
9183

9284
/**

0 commit comments

Comments
 (0)
0