The XOR gate, or Exclusive OR gate, is a logical operation. It's best thought about in binary (only 0 and 1).
The XOR has the following properties:
The XOR is the equivalent of adding the numbers in base 2, modulus 2: (1 + 1) mod 2 = 0, (1 + 0) mod 2 = 1
The XOR logic is either one, but not both. It's an exclusive OR, because it excludes the true case of true OR true, which is ambiguous.
In a chain of XORs, such as 1 XOR 0 XOR 1 XOR 1, an odd number of the inputs need to be true. For example, 1 XOR 0 XOR 1 XOR 1 = 1 because 3 inputs are 1 (odd). 1 XOR 0 XOR 1 XOR 0 = 0 because 2 inputs are 1 (even).
Although the XOR is a bitwise operation for binary numbers, it can be done on numbers in different bases by converting to binary and on strings by writing them by character codes in binary.
What is 11011012 XOR 10010101012?
An XOR in binary is super simple! Let's try it on decimal numbers.
What is 32 XOR 23?
The first part of this problem is converting 32 and 23 from base 10 to base 2. We're going to do this quickly, but if you want to learn more about converting between bases and number bases in general, see this tutorial
Now that we have two base 2 numbers, getting the XOR is as simple as the last problem.
Notice that doing an XOR with a 0 from any digit is that digit, so the last 5 zeroes make this XOR very easy. 100000 XOR 10111 = 110111
If the XOR of 'a' and '-' is 'L', what's the XOR of 'L' and 'a'?
To solve this problem, we would have to convert the characters to their corresponding character codes, then convert that number to binary. Then, we would take the XOR, convert the binary to decimal, and then convert the character code to the ASCII character.
That's... a lot of work. Thankfully, the XOR has a unique property. If a XOR b = c, then a XOR c = b, and b XOR c = a.
In this example, we can see that the XOR would just be '-', without having to do any work.
Let's do that last example again, but through that long process of actually calculating the XOR.
The XOR is a common CTF topic. That's why we've created two XOR tools to help you out. The XOR Calculator quite simply allows you to take the XOR of numbers (binary, decimal, hex) or text.
The XOR Finder allows you to brute force the XOR on text, and filter it to find a specific string and just ASCII.