XOR Calculator

XOR hex, binary or decimal numbers and see the result bit by bit. You can also XOR text with a key or calculate the XOR checksum (BCC) of a byte frame.

How to use the XOR calculator

  1. XOR numbers: enter two or more values, one per line. Prefix hex with 0x, binary with 0b and octal with 0o, or choose a base. Underscores and spaces in long numbers are ignored.
  2. Read the result in hex, decimal, binary and octal. The dark panel lines up every input bit by bit so you can see which columns differ.
  3. XOR text or bytes: combine a message with a key (text or hex), byte by byte with the key repeating. Press Use result as data to run it again and get the original back.
  4. XOR checksum: paste a frame of hex bytes to get its Block Check Character, with options to skip the first (STX) or last byte.

XOR truth table

ABA XOR BMeaning
000Same: 0
011Different: 1
101Different: 1
110Same: 0

XOR (exclusive OR, written ^ in C, Java, JavaScript and Python, and ⊕ in maths) is 1 when an odd number of its inputs are 1. That generalises to many inputs: XOR of a list is the parity of each bit column. Compared with the other gates: AND needs both bits set, OR needs at least one, and XNOR is the inverse of XOR (1 when bits are equal). Try them on the bitwise calculator.

Worked examples

InputsBinaryResult
12 XOR 101100 ⊕ 10100110 = 6
0xF0 XOR 0x3C1111 0000 ⊕ 0011 11001100 1100 = 0xCC
0xF0 XOR 0x3C XOR 0xAA1100 1100 ⊕ 1010 10100110 0110 = 0x66
‘a’ XOR 0x200110 0001 ⊕ 0010 00000100 0001 = ‘A’ (case flip)
0xFF XOR xflips all 8 bitsbitwise NOT of a byte
BCC of 31 32 33 030x31 ⊕ 0x32 ⊕ 0x33 ⊕ 0x030x33

Properties that make XOR useful

XOR checksums (BCC / LRC)

Many serial and embedded protocols append a one-byte Block Check Character: the XOR of the message bytes. Examples include smart-card (ISO 7816) T=1 frames, many RS-232 and RS-485 device protocols, NMEA 0183 sentences from GPS receivers (the two hex digits after * are the XOR of every character between $ and *), and some barcode and payment terminals. To verify a received frame, XOR every byte including the BCC: the answer must be 00. Tick Input is ASCII text to checksum an NMEA sentence body directly. For CRC-16, CRC-32, MD5 or SHA checksums, use the checksum calculator instead; XOR is fast but weaker, because two errors in the same bit column cancel out.

XOR encryption, briefly

XORing data with a key is the core step inside real ciphers such as AES and ChaCha20, and with a truly random key as long as the message it is a one-time pad, which is unbreakable. With a short repeating key, as in this tool, it is only obfuscation: common plaintext like spaces or file headers reveals the key quickly. Use it to learn, to decode CTF puzzles and malware strings, or to understand protocols, not to protect secrets. To convert results between bases, see hex to binary and text to hex.

Frequently asked questions

How do you calculate XOR?

Write the values in binary and compare them bit by bit. Each result bit is 1 when the two input bits are different and 0 when they are the same. For example 1100 XOR 1010 = 0110, so 12 XOR 10 = 6. With more than two values, XOR them one after another; the order does not matter.

How do I XOR two hex numbers?

Enter them one per line with a 0x prefix, or choose Hex as the input base, and read the result in hex, decimal and binary. By hand, XOR each hex digit separately: F XOR 3 is C because 1111 XOR 0011 = 1100. So 0xF0 XOR 0x3C = 0xCC.

What is an XOR checksum or BCC?

A Block Check Character is the XOR of every byte in a message. The sender appends it; the receiver XORs all bytes including the BCC and expects 0. It is used in serial protocols, smart cards, barcode scanners and many embedded devices. It catches any single-bit error, but not two errors in the same bit position.

Should the STX byte be included in the BCC?

It depends on the protocol. Many serial protocols compute the BCC over everything after STX up to and including ETX, so tick Skip first byte. Others include every byte. Check the device's documentation, because the same frame gives a different BCC either way.

How does XOR encryption work?

Each byte of the message is XORed with a byte of the key, repeating the key as needed. XORing the result with the same key restores the original, because A XOR K XOR K = A. With a short repeating key it is easy to break and should only be used for learning or obfuscation, not security.

What is the XOR of a number with itself?

Always 0, and XOR with 0 leaves a number unchanged. These two rules make XOR useful for toggling bits, swapping variables without a temporary, finding the one value that appears an odd number of times in a list, and parity checks.

Can I XOR negative numbers or very large numbers?

Yes. The calculator uses arbitrary-precision integers, so values of any length work, and negative numbers are treated as two's complement, as in most programming languages. The binary view pads to a whole number of bytes.