One Time Pad

One Time Pad

An unbreakable cipher

Note :

This Should not be confused with One time Password.

What is a One-Time-Pad ?

One Time Pad in cryptography is an uncrackable encryption technique as long as the single-use pre-shared key is not smaller than that of the encrypted message.

Message space & Cipher text belong to same space i.e {0,1} pow n. And the key will be a random bit string of the message length.

How One-Time-Pad work?

In this technique, a message/plaintext is paired with an auto-generated random key secret(OTP). Every bit or character of the message is encrypted by combining with corresponding every bit or character from the OTP using modular addition or simply XORing it.

Note: Key used should not be repeated and should be of the same as the message length


Consider Bob wants to send a message to Alice. Both share the same key to encrypt and decrypt messages i.e (XMCKL). Bob encrypts his message "hello" with the secret key XMCKL and gets cipher text EQNVZ. This cipher text is sent to Alice.

Screenshot 2022-08-28 at 9.47.14 AM.png

Alice uses the secret key to decrypt the message.

Screenshot 2022-08-28 at 9.53.13 AM.png

By having only cipher texthe attacker can't getet the message out of it if certain conditions are followed:

  • Key must be at least as long as the message.
  • Key must be random.
  • Key must never be used repeating in whole or in part.
  • Key must be kept completely secret between communicating parties.

Due to these strict conditions, the use of a one-time pad over digital media is impracticable. The most challenging conditions reside in generating truly random keys, the inability to reuse a key, as these keys are same length as the message, sharing these keys with the receiving party is cumbersome and these one-time-pad need to be safely disposed of.

Did you find this article valuable?

Support Shreyas K S by becoming a sponsor. Any amount is appreciated!