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.

Use the One-Time Pad Encrypt / Decrypt Tool

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

A one-time pad (OTP) is the only provably unbreakable cipher when used correctly. This tool XOR-encrypts plaintext with a random key of equal length generated by the browser's WebCrypto API. Ciphertext is shown in both hex and base64. Paste the same key and ciphertext back to decrypt and confirm 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-06-19 · Reviewed by Nham Vu