Home/Glossary/XOR Cipher

XOR Cipher

An encryption method using the XOR (exclusive or) operation to combine plaintext with a key.

CryptographyAlso called: "exclusive or cipher", "xor encryption"

XOR ciphers use bitwise XOR operation for encryption and decryption.

How XOR works

  • 0 XOR 0 = 0, 1 XOR 1 = 0.
  • 0 XOR 1 = 1, 1 XOR 0 = 1.
  • XOR with same key reverses operation: (A XOR B) XOR B = A.

Encryption process

  • Convert plaintext and key to binary.
  • XOR each bit of plaintext with corresponding key bit.
  • Result is ciphertext.
  • XOR ciphertext with same key to decrypt.

Security considerations

  • Key must be random and never reused.
  • One-time pad (OTP) with random key = unbreakable.
  • Key reuse reveals patterns and enables attacks.
  • Used in stream ciphers and network protocols.

Practical uses

  • Teaching encryption concepts.
  • Simple obfuscation (not security).
  • Building block in modern encryption.