public static function compare($known, $user)
    {
        if (strlen($known) !== strlen($user)) {
            return false;
        }
        $result      = 0;
        $knownLength = strlen($known);
        for ($i = 0; $i < $knownLength; $i++) {
            $result |= ord($known[$i]) ^ ord($user[$i]);
        }

        return $result == 0;
    }
public static function compare($known, $user)
    {
        if (strlen($known) !== strlen($user)) {
            return false;
        }
        $result      = 0;
        $knownLength = strlen($known);
        for ($i = 0; $i < $knownLength; $i++) {
            $result |= ord($known[$i]) ^ ord($user[$i]);
        }

        return $result == 0;
    }
public static function compare ( $ known , $ user ) { if ( strlen ( $ known ) !== strlen ( $ user ) ) { return false ; } $ result = 0 ; $ knownLength = strlen ( $ known ) ; for ( $ i = 0 ; $ i < $ knownLength ; $ i ++ ) { $ result |= ord ( $ known [ $ i ] ) ^ ord ( $ user [ $ i ] ) ; } return $ result == 0 ; }
Compares two strings securely.

@link http://blog.astrumfutura.com/2010/10/nanosecond-scale-remote-timing-attacks-on-php-applications-time-to-take-them-seriously/ Implementation source

@param string $known
@param string $user

@return boolean
Compares two strings securely .