function Crypt::hashEquals

Compares strings in constant time.

Parameters

string $known_string: The expected string.

string $user_string: The user supplied string to check.

Return value

bool Returns TRUE when the two strings are equal, FALSE otherwise.

Deprecated

in drupal:8.8.0 and is removed from drupal:9.0.0. Use PHP's built-in hash_equals() function instead.

See also

https://www.drupal.org/node/3054488

1 call to Crypt::hashEquals()
CryptTest::testHashEquals in core/tests/Drupal/Tests/Component/Utility/CryptTest.php
Legacy test of Drupal\Component\Utility\Crypt::hashEquals() method.

File

core/lib/Drupal/Component/Utility/Crypt.php, line 99

Class

Crypt
Utility class for cryptographically-secure string handling routines.

Namespace

Drupal\Component\Utility

Code

public static function hashEquals($known_string, $user_string) {
    @trigger_error(__CLASS__ . '::hashEquals() is deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use PHP\'s built-in hash_equals() function instead. See https://www.drupal.org/node/3054488', E_USER_DEPRECATED);
    return hash_equals($known_string, $user_string);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.