Skip to main content
Modern basics100% FreeInstant

XOR Cipher: Encrypt and Decrypt Text with a Key

This free XOR cipher tool combines your text with a repeating key using the XOR operation and shows the result as hex. Paste the hex back with the same key to decrypt it.

By Debmedia Technologies LLP · Kolkata, India · Updated

What Is It and When Do You Need It?

XOR is the building block of many modern ciphers. A repeating-key XOR cipher is simple, and it is a classic first exercise in cryptography courses and capture-the-flag games.

Enter text and a key to get hex, or paste hex and the key to get the text back.

How to Use This Tool

  1. Type your text, or paste hex to decrypt.
  2. Enter the key.
  3. Choose the direction.
  4. Press Run.

How the Calculation Works

The text and key are turned into bytes with UTF-8. Each byte of the text is XORed with the next byte of the key, and the key repeats. The result bytes are shown as hex. Decryption does the same on the hex bytes and reads the result as text.

Worked Example

The text abc with the key k gives the bytes 0A 09 08, shown as 0a0908.

Common Uses

  • Teaching cryptography.
  • Capture-the-flag challenges.
  • Simple obfuscation.
  • Understanding XOR.

Tips and Common Mistakes

  • Never use a short repeating key for real secrets.
  • The key must not be empty.
  • Hex input may include spaces.

Next, you may need the Vigenère cipher, bitwise calculator, checksum calculator, Caesar cipher.

Everything runs in your browser. Nothing you type is uploaded, stored or sent to any outside service.

Frequently Asked Questions

Exclusive OR is an operation on bits: the result is 1 when the two bits differ and 0 when they are the same.
XOR with the same key twice gives back the original, because a ^ k ^ k equals a.
Only if the key is random, as long as the message and never used again (a one-time pad). With a short repeating key it is easy to break.
The XOR result may contain unprintable bytes, so hex is the safe way to show it.

Disclaimer: results are calculated in your browser from the numbers you enter. Check important results before you rely on them for money, health, safety or legal decisions.