We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ac7ddaf commit 74973e0Copy full SHA for 74973e0
src/Symfony/Component/Security/Core/Util/StringUtils.php
@@ -15,6 +15,7 @@
15
* String utility functions.
16
*
17
* @author Fabien Potencier <fabien@symfony.com>
18
+ * @author Kévin Dunglas <dunglas@gmail.com>
19
*/
20
class StringUtils
21
{
@@ -35,6 +36,11 @@ private function __construct() {}
35
36
37
public static function equals($knownString, $userInput)
38
39
+ // Use hash_equals if applicable
40
+ if (function_exists('hash_equals') && strlen($knownString) === strlen($userInput)) {
41
+ return hash_equals($knownString, $userInput);
42
+ }
43
+
44
// Prevent issues if string length is 0
45
$knownString .= chr(0);
46
$userInput .= chr(0);
0 commit comments