0% found this document useful (0 votes)
45 views22 pages

One-Time Pad Cipher

Uploaded by

Suyen Carillo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views22 pages

One-Time Pad Cipher

Uploaded by

Suyen Carillo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 22

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

Rules of encryption is as follows:


1. Assign a number to each character of the plain-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

3
Vernam Cipher

Rules of encryption is as follows:


2. Assign a number to each character of the plain-Text and the key according to
alphabet order. Plain Text I A M A N I N D I A N
8 0 12 0 13 8 13 3 8 0 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
4
13 14 15 16 17 18 19 20 21 22 23 24 25
Vernam Cipher

Rules of encryption is as follows:


3. Add both the number (Corresponding plain-text character number and Key
character number).
Plain Text I A M A N I N D I A N
8 0 12 0 13 8 13 3 8 0 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 (P.T. + Key) 8 13 31 8 28 8 23 11 26 19 13

5
Vernam Cipher

Rules of encryption is as follows:


4. Subtract the number from 26 if the added number is greater than 26. Otherwise,
left it. Assign alphabets of numbers, it produce cipher text.
Plain Text I A M A N I N D I A N
8 0 12 0 13 8 13 3 8 0 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 (P.T. + Key)
8 13 31 8 28 8 23 11 26 19 13

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

▰ Improvement to the Vernam cipher.


▰ It yields the ultimate in security
▰ Random key that is as long as the message
▰ The key need not to be repeated
▰ In addition, the key is to be used to encrypt and decrypt a single message, and
then discarded.
▰ Each new message requires a new key of the same length as the new message.
▰ Such a scheme, known as a one-time pad, is unbreakable.

11
One-Time Pad Cipher

▰ It produce random output.


▰ No statistical relationship to the plaintext.
▰ code. Because the ciphertext contains no information whatsoever about the
plaintext, there is simply no way to break the
▰ The code is unbreakable.
▰ The security of the one-time pad is entirely due to the randomness of the key.

12
One-Time Pad Cipher

Two Fundamental Difficulties


▰ The practical problem of making large quantities of random keys.
▰ Even more daunting is the problem of key distribution and protection.
▰ Because of these difficulties, the one-time pad is of limited utility and is useful
primarily for low-bandwidth channels requiring very high security.

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

Python Program to Implement the One Time Pad Algorithm


•Encryption:
• For each character in the plaintext and the corresponding character in the
key, we calculate the new character using the formula:
encrypted_char=(ord(p)−ord(′A′)+ord(k)−ord(′A′)mod 26)+ord(′A′)
• This wraps around the alphabet by using modulo 26.

•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

You might also like