src/Yubikey.php
protected static function hashEquals($knownString, $userString)
    {
        static $exists = null;
        if ($exists === null)  $exists = \function_exists('\\hash_equals');
        if ($exists)  return \hash_equals($knownString, $userString);
        $length = self::safeStrlen($knownString);
        if ($length !== self::safeStrlen($userString)) return false;
        $r = 0;
        for ($i = 0; $i < $length; ++$i) {
            $r |= \ord($userString[$i]) ^ \ord($knownString[$i]);
        }
        return $r === 0;
    }
protected static function hashEquals($knownString, $userString)
    {
        static $exists = null;
        if ($exists === null)  $exists = \function_exists('\\hash_equals');
        if ($exists)  return \hash_equals($knownString, $userString);
        $length = self::safeStrlen($knownString);
        if ($length !== self::safeStrlen($userString)) return false;
        $r = 0;
        for ($i = 0; $i < $length; ++$i) {
            $r |= \ord($userString[$i]) ^ \ord($knownString[$i]);
        }
        return $r === 0;
    }
protected static function hashEquals ( $ knownString , $ userString ) { static $ exists = null ; if ( $ exists === null ) $ exists = \ function_exists ( '\\hash_equals' ) ; if ( $ exists ) return \ hash_equals ( $ knownString , $ userString ) ; $ length = self :: safeStrlen ( $ knownString ) ; if ( $ length !== self :: safeStrlen ( $ userString ) ) return false ; $ r = 0 ; for ( $ i = 0 ; $ i < $ length ; ++ $ i ) { $ r |= \ ord ( $ userString [ $ i ] ) ^ \ ord ( $ knownString [ $ i ] ) ; } return $ r === 0 ; }
Compare two hashes in constant time

@param string $knownString
@param string $userString
@return boolean
Compare two hashes in constant time