One-Time Pad
Encrypt and decrypt with a pad that is at least as long as the message, or generate fresh pad material from your browser's cryptographic RNG. Supports letters, digits, and bytewise XOR.
Encrypt with a pad that is never repeated
A one-time pad is simple but strict: the pad must be random, at least as long as the message, and used once. This tool enforces the length rule instead of repeating a short key like a Vigenère or repeating-XOR cipher would. If the pad is too short, it stops with an error that names the shortfall.
Choose one of three alphabets:
- Letters — adds pad letters to message letters with
C = (P + K) mod 26. Case, spaces, punctuation, and numbers are preserved and do not consume pad. - Digits — the same idea over
0..9withC = (P + K) mod 10. Non-digits pass through unchanged. - XOR bytes — XORs the UTF-8 bytes of the message with random pad bytes, with pad and ciphertext encoded as hex or Base64.
Leave Pad empty while encrypting to generate a fresh pad sized to the message. Use Generate pad when you only need pad material. Random pads come from the platform cryptographic RNG; generated letter and digit pads use rejection sampling so the alphabet is uniform.
Worked example
For the classic letter example:
- Message:
HELLO - Pad:
XMCKA - Mode:
encrypt - Cipher:
letters
The result is EQNVO because each letter is added modulo 26: H + X = E, E + M = Q, L + C = N, L + K = V, O + A = O. Switch to Decrypt with message EQNVO and the same pad XMCKA to recover HELLO.
Limits and edge cases
- Maximum message/pad work is 16,384 letters, digits, or bytes per run.
- Group output every N characters is for display only.
0keeps the original layout;5creates classic five-character groups;20is the maximum. - Letter and digit modes preserve characters outside their alphabet. Those characters are not encrypted and do not consume pad.
- XOR decrypt expects the ciphertext in the selected encoding and returns UTF-8 text. If the pad or encoding is wrong, decrypted bytes may not be valid UTF-8.
- Generated pads are returned so you can store or share them out of band. Never reuse the same pad material for another message.
FAQ
How is this different from the XOR cipher tool?
The XOR cipher tool applies a repeating key, which is useful for demos and byte manipulation but is not a one-time pad. This tool requires pad material at least as long as the transformed message and never repeats it. That strict length rule is the security property.
Why do spaces and punctuation not use up pad letters?
In the letter and digit modes only the selected alphabet is transformed. Spaces, punctuation, and other characters are copied through so formatted messages stay readable. If you need every byte encrypted, choose XOR bytes instead.
Can I leave the pad blank?
Yes, but only for encryption. An empty pad in Encrypt mode generates a fresh random pad sized to the message and returns it with the ciphertext. Decryption always requires the exact pad that was used to encrypt.
Is the generated pad cryptographically random?
The block uses the platform cryptographic random source: WebCrypto in the browser page and WASI randomness in the sandboxed tool runtime. Letter and digit pads use rejection sampling rather than a biased modulo shortcut.
What happens if the pad is longer than the message?
Only the required prefix is used and the result includes a warning. Do not treat the unused suffix as safe spare pad material unless you manage pad pages carefully outside this stateless tool; accidental reuse breaks one-time-pad security.
Developer & Automation Access
Run it from the terminal
Same engine as this page, headless — via the gizza CLI:
gizza tool one-time-pad 'mode=encrypt'New to the CLI? Get gizza →
Open it by URL
Pre-fill and auto-run this tool with query parameters — the names match the API/CLI:
https://gizza.ai/tools/one-time-pad/?mode=encrypt&cipher=letters&message=HELLO&pad=XMCKA%20%28leave%20empty%20while%20encrypting%20to%20generate%20a%20fresh%20pad%29&encoding=hex&length=0&group=0Machine-readable descriptor: tool.json — title + parameters JSON Schema for agents.
