One-Time Pad Calculator
Encrypt text with a key at least as long as the message.
What it does
The one-time pad is the simplest cipher with a mathematical proof of secrecy. Each letter of the message is combined with a letter from a random key of the same length, using addition modulo 26 in the version shown here.
University of Maryland cryptography notes describe the Vigenere style construction and the modular arithmetic behind it. Boston University notes define perfect secrecy and explain why a uniformly random key as long as the message achieves it.
The proof depends on strict conditions. The key must be generated randomly, kept secret, used once and never reused. If any of those conditions fail, the ciphertext can leak information about the plaintext.
This tool strips non letters, uppercases the text and adds the key modulo 26. It rejects a key shorter than the message rather than repeating it.
The example key is fixed for illustration. Real use requires a fresh random key for every message.
How to use
- Type a plaintext using letters.
- Type a key with at least as many letters as the plaintext.
- Read the ciphertext in the main result.
- Check the key actually used, which is the leading portion of what you entered.
- Try the default HELLO with key XMCKL to reproduce the worked example.
- Remember never to reuse a real key.
Formula
- p(i)
- Numerical value of plaintext letter i.
- k(i)
- Numerical value of key letter i.
- c(i)
- Numerical value of ciphertext letter i.
- mod 26
- Wraparound within the 26 letter alphabet.
The engine removes non letters from both inputs and requires the key to be at least as long as the plaintext. It does not test randomness, because that is a property of how the key was generated.
Worked example
Example: HELLO with key XMCKL
Plaintext HELLO and key XMCKL.
- H is 7 and X is 23, giving 30 modulo 26, which is 4 or E.
- E is 4 and M is 12, giving 16, which is Q.
- L is 11 and C is 2, giving 13, which is N.
- The next L with K gives 21, which is V.
- O is 14 and L is 11, giving 25, which is Z.
- The ciphertext is EQNVZ.
- The tool reports ciphertext EQNVZ, key XMCKL and 5 letters encrypted.
Reference table
| Plain | Plain value | Key | Key value | Cipher |
|---|---|---|---|---|
| H | 7 | X | 23 | E |
| E | 4 | M | 12 | Q |
| L | 11 | C | 2 | N |
| L | 11 | K | 10 | V |
| O | 14 | L | 11 | Z |
Limits
- The tool uses the 26 letter English alphabet only.
- It does not verify that the key is random.
- It does not decrypt or detect key reuse.
- A key shorter than the message is rejected.
Common mistakes
- Reusing a key for more than one message.
- Using a predictable key such as a word from the dictionary.
- Entering a key shorter than the plaintext and expecting repetition.
- Assuming any long key gives perfect secrecy without randomness.
- Expecting the cipher to hide message length, which it does not.
Try it yourself
Quick checks. Answers sit tucked under each question.
Encrypt HELLO with key XMCKL.
EQNVZ, from adding each pair of letter values modulo 26.
What makes a one-time pad perfectly secret?
A truly random key, as long as the message, kept secret and never reused.
What happens if the key is reused?
An attacker can combine the two ciphertexts and learn information about both messages.
Questions
What is a one-time pad?
A cipher where each message letter is combined with a random key letter of the same length.
Why is it called perfect?
Because every plaintext of the same length is equally likely given the ciphertext, when the key is truly random.
Can I use a phrase as the key?
Not safely. Predictable text does not have the required randomness.
What if the key is shorter?
The tool rejects it. Repeating a short key turns this into a Vigenere cipher.
Does the tool decrypt?
No. It performs encryption only.
Is this used today?
In niche high security settings with careful key management, but random key distribution is difficult.
Sources
- University of Maryland, Vigenere, Matrix Cipher and One-Time Pad
- Boston University, Perfect Secrecy and the One-Time Pad