I have this function in PHP
for ($i = 0; $i < $payloadLength; $i++) {
$frame .= ($masked === true) ? $payload[$i] ^ $mask[$i % 4] : $payload[$i];
}
Or to make things just a little bit less complex, the following returns the same:
if ($masked == true) {
$result = $payload[$i] ^ $mask[$i % 4];
} else {
$result = $payload[$i];
}
$frame .= $result;
And I am focused on this line:
$result = $payload[$i] ^ $mask[$i % 4];
The ^ symbol represents the XOR BitWise and the % is a Modulus Arithmetic Operator but I haven’t found this Modulus feature in Xojo Manual and the BitWise is a little bit tricky to be honest. Also, according the manual BitWise is expecting an Integer ? Is that right ?
Could someone with BitWise experience assist me in translating this in to Xojo language ?
The $payload is a String (i.e: “Hello Word!”) and with the [$i] in front of it, it will catch that character space, one by one, like Mid in Xojo
The $mask is an array(3) with some a random Chrs from 0 to 255… but I don’t know how to obtain the % same result in Xojo.
So far, my best guess is (incomplete):
Dim result As String
result = payload(payload.Mid(i, i+1)) ^ mask(i % 4)