public static function compare($known, $user)
{
if (function_exists('hash_equals')) {
return hash_equals($known, $user);
}
if (!is_string($known) || !is_string($user)) {
trigger_error('Expected `$known` & `$user` parameters to be strings.', E_USER_WARNING);
return false;
}
if (($length = strlen($known)) !== strlen($user)) {
return false;
}
for ($i = 0, $result = 0; $i < $length; $i++) {
$result |= ord($known[$i]) ^ ord($user[$i]);
}
return $result === 0;
}