One-Time Pad XOR Tool

Enter a message and key, choose encrypt or decrypt, and XOR them together.

How it is calculated

The tool works on bytes. To encrypt it takes each byte of the message and combines it with the matching byte of the key using XOR: Ci = Pi ⊕ Ki mod len. If the key is shorter than the message it is repeated. Each result byte is written as two uppercase hex digits. To decrypt, paste the hex (spaces are ignored; it needs an even number of hex digits), and the tool XORs each byte with the same key and returns the text. Because XOR undoes itself, the same key restores the original. Characters outside plain ASCII use several bytes, so the byte count can exceed the character count. A wrong key on decrypt gives garbage or unprintable characters, and an empty message or key gives no result.

Worked example

Encrypt HELLO with the key XMCKL, which has the same length as the message. In hex the letters H E L L O are 48 45 4C 4C 4F and the key letters X M C K L are 58 4D 43 4B 4C. XOR pair by pair: 48 ⊕ 58 = 10, 45 ⊕ 4D = 08, 4C ⊕ 43 = 0F, 4C ⊕ 4B = 07, 4F ⊕ 4C = 03. The output is 10080F0703 and the byte count is 5. Switching to decrypt with the same key and this hex returns HELLO.

Try this example →

Common mistakes

  • Believing the output is unbreakable. It is only a true one-time pad if the key is random, as long as the message and never used again; a short, repeated or guessable key like a word can be broken.
  • Reusing one key for two messages. XOR-ing the two ciphertexts cancels the key and exposes the relation between the plaintexts.
  • Pasting ordinary text in decrypt mode. Decryption expects hex digits only; plain words or an odd number of digits give no result.
  • Using a different key or changing a character when decrypting. A single wrong key byte changes the matching output byte, so the text comes out garbled.
  • Counting characters instead of bytes. An accented letter such as ü takes two bytes, so the byte length and hex output are longer than you might expect.

About this calculator

The one-time pad, formalized by Gilbert Vernam, achieves theoretically perfect secrecy by combining each plaintext byte with a key byte of equal length using XOR — a reversible bitwise operation where applying the same key twice returns the original data (P ⊕ K = C, then C ⊕ K = P). Perfect secrecy only holds if the key is truly random, exactly as long as the message, and never reused; in practice, the same math with a short repeating key (as this tool does) produces a simple, breakable stream cipher rather than a true unbreakable pad.

This tool XORs a message against a key — repeating the key to match the message length — to encrypt text into hex or decrypt hex back into text. Cryptography students use it to see XOR-based encryption mechanics firsthand, and CTF players and security learners use it to quickly encode or decode XOR-cipher challenges by hand.

Was this helpful?

You can pick up to 3 reactions.

Comments (1)

  • Editorial team

    One handy quirk when encrypting: wherever a message byte equals the matching key byte, the output byte is 00, because anything XORed with itself is zero. Long runs of 00 in the hex therefore mean the key is echoing the plaintext at those spots, which is a good sign the key is too short or too guessable. Do you use this for coursework or puzzle challenges, and what kind of key lengths do you try?

Popular calculators

All Calculators