One-Time Pad Cipher
One-Time Pad Cipher
Lecture 5
One-Time Pad Cipher
▰ Also called “Vernam Cipher” or the perfect cipher, is a crypto algorithm where
plaintext is combined with a random key.
▰ The key is at least as long as the message or data that must be encrypted.
▰ Each key is used only once, and both sender and receiver must destroy their key
after use.
▰ There should only be two copies of the key: one for the sender and one for the
receiver.
2
Vernam Cipher
3
Vernam Cipher
a b c d e f g h i j k l m
0 1 2 3 4 5 6 7 8 9 10 11 12
n o p q r s t u v w x y z
4
13 14 15 16 17 18 19 20 21 22 23 24 25
Vernam Cipher
5
Vernam Cipher
6
SUM-26 (if SUM>25) 8 13 5 8 2 8 23 11 0 19 13
Vernam Cipher
Decryption Process:
1. Assign a number to each character of the Cipher text, like (a=0, b=1, c=2,… z=25).
As per given table.
a b c d e f g h i j k l m
0 1 2 3 4 5 6 7 8 9 10 11 12
n o p q r s t u v w x y z
13 14 15 16 17 18 19 20 21 22 23 24 25
7
Vernam Cipher
Decryption Process:
2. Assign a number to each character of the Cipher text and the key according to
alphabetical order.
Cipher Text I N F I C I X L A T N
8 13 5 8 2 8 23 11 0 19 13
Key A N T I P A K I S T A
0 13 19 8 15 0 10 8 18 19 0
a b c d e f g h i j k l m
0 1 2 3 4 5 6 7 8 9 10 11 12
n o p q r s t u v w x y z
8
13 14 15 16 17 18 19 20 21 22 23 24 25
Vernam Cipher
Decryption Process:
3. Subtract cipher text alphabet number from key alphabet number (Reverse process
of encryption)
Cipher Text I N F I C I X L A T N
8 13 5 8 2 8 23 11 0 19 13
Key A N T I P A K I S T A
0 13 19 8 15 0 10 8 18 19 0
SUM (C.T. - Key) 8 0 -14 0 -13 8 13 3 -18 0 13
9
Vernam Cipher
Decryption Process:
4. If any number less than zero then add 26 in that number, otherwise left it.
Cipher Text I N F I C I X L A T N
8 13 5 8 2 8 23 11 0 19 13
Key A N T I P A K I S T A
0 13 19 8 15 0 10 8 18 19 0
SUM (C.T. - Key) 8 0 -14 0 -13 8 13 3 -18 0 13
SUM=26 (if SUM<0) 8 0 12 0 13 8 13 3 8 0 13
10
Plain Text I A M A N I N D I A N
One-Time Pad Cipher
11
One-Time Pad Cipher
12
One-Time Pad Cipher
13
One-Time Pad Cipher
Perfect Secrecy
▰ The one-time pad is the only cryptosystem that exhibits what is referred to as
perfect secrecy.
Perfect secrecy is the notion that, given an encrypted message (or ciphertext) from
a perfectly secure encryption system (or cipher), absolutely nothing will be revealed
about the unencrypted message (or plaintext) by the ciphertext).
14
One-Time Pad Cipher
One-time pad cipher is a type of Vignere cipher which includes the following features −
▰ It is an unbreakable cipher.
▰ The key is exactly same as the length of message which is encrypted.
▰ The key is made up of random symbols.
▰ As the name suggests, key is used one time only and never used again for any
other message to be encrypted.
Due to this, encrypted message will be vulnerable to attack for a cryptanalyst. The key
used for a one-time pad cipher is called pad, as it is printed on pads of paper.
15
One-Time Pad Cipher
Why is it Unbreakable?
The key is unbreakable owing to the following features −
▰ The key is as long as the given message.
▰ The key is truly random and specially auto-generated.
▰ Key and plain text calculated as modulo 10/26/2.
▰ Each key should be used once and destroyed by both sender and receiver.
▰ There should be two copies of key: one with the sender and other with the
receiver.
16
One-Time Pad Cipher
Encryption
To encrypt a letter, a user needs to write a key underneath the plaintext. The plaintext
letter is placed on the top and the key letter on the left. The cross section achieved
between two letters is the plain text. It is described in the example below −
17
One-Time Pad Cipher
Decryption
To decrypt a letter, user takes the key letter on the left and finds cipher text letter in that
row. The plain text letter is placed at the top of the column where the user can find the
cipher text letter.
18
One-Time Pad Cipher
•Decryption:
•The decryption reverses the encryption process using a similar formula,
ensuring the result wraps around correctly with + 26 to handle negative values .
19
One-Time Pad Cipher
Code:
20
One-Time Pad Cipher
Output:
21
THANKS!
22