XOR Calculator

Exclusive OR two values and see which columns disagreed, with the answer in four bases.

Operand A
Operand B
XOR result
Runs locally in your browser

About the XOR Calculator

Exclusive OR marks a column with a 1 when the operands disagree there and a 0 when they match. That single rule gives XOR its two famous properties: applying the same value twice returns the original number, and XORing a value with itself always yields zero. Both facts are visible in the bit layout this page prints under the answer.

Those properties turn up everywhere. Parity bits are the XOR of a message. RAID recovers a lost drive by XORing the survivors. Simple stream ciphers XOR plaintext against a keystream, and the classic three step swap trick exchanges two registers without a scratch variable. Checksums such as the Longitudinal Redundancy Check are nothing more than a running XOR over the bytes of a frame.

Type operands in decimal or tag them with 0x, 0b or 0o; the input base selector can also pin the interpretation for a pasted column of values. Extra lines are folded into the same operation, which is how a parity byte over a frame is calculated in one go. The word size defaults to the narrowest that fits, and the signed line shows the same bits read as a two’s complement integer. For real encryption rather than a bit trick, use the Encrypt Decrypt tool, and for a letter shifting cipher see ROT13.

How to use

  1. Paste the first value into Operand A.
  2. Paste the value you want to XOR against it into Operand B.
  3. Add further lines to fold a whole run of bytes into one parity value.
  4. Check the Result bits set line to see which positions differed.

Common questions

Why does XOR undo itself?
A column flips when the two inputs differ. Applying the same operand a second time flips exactly the same columns back, returning the original value.
Is XOR encryption secure?
Only with a truly random key as long as the message and never reused. A short repeated key is broken quickly by frequency analysis.
How do I compute a parity byte?
Put every byte of the frame on its own line across the two panes. The folded result is the XOR parity of the whole run.
What does XOR with 0xFF do?
It inverts all eight bits, giving the same answer as a NOT on an 8-bit word.