Find b given x and a where a ^ b = x

Viewed 45

Given the result of an XOR operation and one of the operands involved in said operation, how can I go about finding the other operand? Specifically, given the knowledge that x = a ^ b and the value of x and a, how can I find b?

1 Answers

We have that:

x = a ^ b
==> x ^ a = a ^ b ^ a
==> x ^ a = (a ^ a) ^ b
==> x ^ a = 0 ^ b
==> x ^ a = b

So, to recover b, you can do:

x ^ a
Related