yii\web\Request::xorTokens PHP Method

xorTokens() private method

If the two strings are of different lengths, the shorter one will be padded to the length of the longer one.
private xorTokens ( string $token1, string $token2 ) : string
$token1 string
$token2 string
return string the XOR result
    private function xorTokens($token1, $token2)
    {
        $n1 = StringHelper::byteLength($token1);
        $n2 = StringHelper::byteLength($token2);
        if ($n1 > $n2) {
            $token2 = str_pad($token2, $n1, $token2);
        } elseif ($n1 < $n2) {
            $token1 = str_pad($token1, $n2, $n1 === 0 ? ' ' : $token1);
        }
        return $token1 ^ $token2;
    }