One-Time Pad Encrypt / Decrypt Tool

Encrypt or decrypt text with a one-time pad (XOR cipher). Generate a cryptographically random key via WebCrypto, view hex/base64 output, and verify the round-trip.

Encrypt

Decrypt

How it works: Each plaintext byte is XOR-ed with a matching key byte. The key is generated by crypto.getRandomValues() (WebCrypto) — no server contact, no storage. Keep the key secret; lose it and the ciphertext is unrecoverable.
Copied!

Summary

Encrypt or decrypt text with a one-time pad (XOR cipher). Generate a cryptographically random key via WebCrypto, view hex/base64 output, and verify the round-trip.

How it works

  1. Type or paste your plaintext into the message field.
  2. Click "Generate Key" to create a cryptographically random key (same byte length as your message) via WebCrypto.
  3. Click "Encrypt" — each message byte is XOR-ed with the matching key byte; ciphertext appears in hex and base64.
  4. To decrypt, paste the ciphertext (hex or base64) and the original key, then click "Decrypt" to recover the plaintext.
  5. The round-trip indicator confirms the decrypted output matches the original message.

Use cases

  • Demonstrate perfect secrecy in a cryptography class or tutorial.
  • Encrypt short secrets offline without any server round-trip.
  • Test XOR-cipher logic during security research or CTF challenges.
  • Generate and exchange a one-time pad key for manual secure messaging.

Frequently Asked Questions

Last updated: 2026-07-01 · Reviewed by Nham Vu