private function compareStrings($knownString, $userString)
    {
        $result = "\x00";

        for ($i = 0, $length = strlen($knownString); $i < $length; $i++) {
            $result |= $knownString[$i] ^ $userString[$i];
        }

        return $result === "\x00";
    }
private function compareStrings($knownString, $userString)
    {
        $result = "\x00";

        for ($i = 0, $length = strlen($knownString); $i < $length; $i++) {
            $result |= $knownString[$i] ^ $userString[$i];
        }

        return $result === "\x00";
    }
private function compareStrings ( $ knownString , $ userString ) { $ result = "\x00" ; for ( $ i = 0 , $ length = strlen ( $ knownString ) ; $ i < $ length ; $ i ++ ) { $ result |= $ knownString [ $ i ] ^ $ userString [ $ i ] ; } return $ result === "\x00" ; }
Compares two string in constant time.
@param string $knownString String known to be correct by the system
@param string $userString String submitted by the user for comparison
@return bool True if the strings are equal, false if not
Compares two string in constant time .