One-Time Pad Generator
Generate cryptographically random one-time pads and encrypt or decrypt messages with modular or XOR cipher modes entirely in your browser.
Updated
What is the One-Time Pad Generator?
A one-time pad (OTP) is the only encryption method with perfect secrecy: when the key is truly random, at least as long as the message, and never reused, the ciphertext reveals nothing about the plaintext—even to an attacker with unlimited computing power.
This free browser tool lets you:
- Generate cryptographically random pads using the Web Cryptography API (
crypto.getRandomValues) - Choose character sets: classic A–Z letters, alphanumeric, hex, base64 alphabet, or printable ASCII
- Encrypt and decrypt with either the traditional modular (letter) Vernam cipher or byte-wise XOR
- Auto-create a matching-length key when you encrypt
- Copy or download pads and results as plain text
Everything runs 100% client-side. No data ever leaves your device. Ideal for learning, demonstrations, CTF practice, or offline experimentation with information-theoretic security.
How it works
1. Generate a one-time pad
Choose a length and character set, then click Generate pad. The tool draws entropy from your browser’s CSPRNG and maps the random bytes onto the selected alphabet. Optional 5-character grouping follows the classic paper-pad convention for easier copying and error checking.
Approximate Shannon entropy is shown so you can see how much uncertainty the pad carries.
2. Choose a cipher mode
- Modular (A–Z) — Classic Vernam cipher. Letters are mapped to numbers 0–25. Encryption adds the key letter modulo 26; decryption subtracts. Non-letter characters (spaces, punctuation, digits) are left unchanged and do not consume key material. Case of the original message is preserved.
- XOR (bytes) — The message is UTF-8 encoded and each byte is XORed with the corresponding key byte. Works with any Unicode text. The key can be supplied as hex, base64, or raw Latin-1 characters. Ciphertext is offered as a UTF-8 interpretation, hex, and base64.
3. Encrypt or decrypt
Paste (or type) the message. For encryption you can enable auto-generate key so a fresh pad of exact required length is created automatically. For decryption you must supply the identical pad that was used for encryption.
The tool validates that the key is long enough and that encodings are well-formed, then shows the result together with statistics (letters or bytes processed, key remaining).
4. Handle the key safely
Copy or download both the ciphertext and the key. A one-time pad must be used exactly once. After successful decryption both parties should securely destroy the used portion. Never transmit the pad over the same channel as the ciphertext, and never reuse any part of it.
Examples
Classic letter pad encryption
Encrypt a short message with a modular A–Z one-time pad. Only letters are shifted; spaces and punctuation stay in place.
Generate a 50-character A–Z pad
Create a classic uppercase letter pad of length 50, optionally grouped in traditional five-character blocks for easy transcription.
XOR byte encryption of Unicode text
Encrypt any UTF-8 message by XORing its bytes with a random key. Ciphertext can be viewed as hex or base64 for safe transport.
Frequently asked questions
What is a one-time pad and why is it unbreakable?
What is a one-time pad and why is it unbreakable?
A one-time pad encrypts each symbol of a message with a corresponding symbol from a truly random key of equal or greater length. Because every possible plaintext is equally likely given the ciphertext (when the key is random and used only once), an attacker learns nothing about the original message—even with infinite computing power. This property is called perfect secrecy and was proved by Claude Shannon.
Does this tool send my messages or keys to a server?
Does this tool send my messages or keys to a server?
No. All generation, encryption, and decryption happen entirely in your browser using the Web Cryptography API. Nothing is uploaded or logged.
Which random number generator is used?
Which random number generator is used?
Pads are produced with crypto.getRandomValues(), the standard browser interface to the operating system’s cryptographically secure random number generator. It draws from hardware entropy sources and is suitable for cryptographic keys.
What is the difference between modular and XOR mode?
What is the difference between modular and XOR mode?
Modular mode operates only on the 26 English letters (A–Z). It adds or subtracts key letters modulo 26 and leaves spaces and punctuation untouched. XOR mode works on the raw UTF-8 bytes of any text, including Unicode characters, and produces binary-safe output that can be shown as hex or base64.
Why must the key be at least as long as the message?
Why must the key be at least as long as the message?
If the key is shorter and is repeated or padded, the construction ceases to be a one-time pad and becomes a stream cipher that can be broken (the classic “two-time pad” attack). The tool therefore rejects keys that are too short for the chosen mode.
Can I reuse a pad for multiple messages?
Can I reuse a pad for multiple messages?
Never. Reusing even a single key segment against two different plaintexts allows an attacker to recover information by XORing the two ciphertexts. Always generate a fresh pad (or use a fresh unused segment) for every message and destroy used material on both ends.
How should I store and share the pad?
How should I store and share the pad?
Share the pad through a separate, secure channel (ideally in person or via a previously established trusted medium). Store unused pads offline in a physically protected location. After use, securely wipe both the electronic and any paper copies.
Why does modular mode ignore non-letter characters?
Why does modular mode ignore non-letter characters?
Traditional letter-based one-time pads only define operations on an alphabet of 26 symbols. Spaces, punctuation, and digits are therefore left in place so the resulting text remains readable for manual checking. Only alphabetic characters consume key material.
Is the slight bias from modulo mapping a problem?
Is the slight bias from modulo mapping a problem?
For alphabet sizes that are not powers of two, reducing a random byte modulo the alphabet size introduces a tiny statistical bias. For educational use and short messages this is negligible. Production systems that require perfect uniformity typically use rejection sampling; this tool prioritizes simplicity and speed while still drawing from a CSPRNG.
Can I use this for real high-stakes secrets?
Can I use this for real high-stakes secrets?
The mathematics are sound, but practical security also depends on key generation, distribution, storage, and destruction discipline. Most real-world systems prefer authenticated encryption (e.g., AES-GCM) because key management for large one-time pads is difficult. Treat this tool as an excellent learning and demonstration environment rather than a drop-in replacement for modern cryptographic protocols.
Related tools
More utilities you might find handy.
Atbash Cipher
Encode and decode text using the Atbash cipher.
Caesar Cipher
Encrypt text with a custom Caesar shift cipher or decrypt unknown messages instantly.
Playfair Cipher Encrypt & Decrypt
Encrypt and decrypt text using the Playfair cipher with interactive 5x5 key square and visual step-by-step guide.