One-Time Pad Calculator

Encrypt text with a key at least as long as the message.

Technology and NetUpdated 2026-11-202 min read
One-Time Pad Calculator
Letters only. Spaces and punctuation are ignored.
Must be at least as long as the plaintext and truly random for real security.
Ciphertext
...
Key used...
Letters encrypted...

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

  1. Type a plaintext using letters.
  2. Type a key with at least as many letters as the plaintext.
  3. Read the ciphertext in the main result.
  4. Check the key actually used, which is the leading portion of what you entered.
  5. Try the default HELLO with key XMCKL to reproduce the worked example.
  6. Remember never to reuse a real key.

Formula

c(i) = (p(i) + k(i)) mod 26, where letters are numbered A = 0 through Z = 25.
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.

  1. H is 7 and X is 23, giving 30 modulo 26, which is 4 or E.
  2. E is 4 and M is 12, giving 16, which is Q.
  3. L is 11 and C is 2, giving 13, which is N.
  4. The next L with K gives 21, which is V.
  5. O is 14 and L is 11, giving 25, which is Z.
  6. The ciphertext is EQNVZ.
  7. The tool reports ciphertext EQNVZ, key XMCKL and 5 letters encrypted.

Reference table

Letter arithmetic for the worked example
PlainPlain valueKeyKey valueCipher
H7X23E
E4M12Q
L11C2N
L11K10V
O14L11Z

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

How this page was checked. The formula above was matched against the cited sources, and the worked example was run through the tool on this page before publishing. If you spot an error, contact us so we can fix it and note the correction.