0% found this document useful (0 votes)
39 views4 pages

Experiment No: 7: Name: Rhugved Satardekar Roll No: 17141208

The document describes an experiment on implementing and analyzing the advantages of a polyalphabetic cipher. It provides background on polyalphabetic ciphers, including that they use multiple substitution alphabets to encrypt plaintext letters at different positions. The Vigenere cipher is discussed as a well-known example that uses sequential Caesar ciphers with key-based shifts. The main advantage described is that polyalphabetic ciphers make frequency analysis more difficult by encrypting the same plaintext letter to different ciphertext letters. Python code is also included to encrypt and decrypt messages using a polyalphabetic cipher.

Uploaded by

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

Experiment No: 7: Name: Rhugved Satardekar Roll No: 17141208

The document describes an experiment on implementing and analyzing the advantages of a polyalphabetic cipher. It provides background on polyalphabetic ciphers, including that they use multiple substitution alphabets to encrypt plaintext letters at different positions. The Vigenere cipher is discussed as a well-known example that uses sequential Caesar ciphers with key-based shifts. The main advantage described is that polyalphabetic ciphers make frequency analysis more difficult by encrypting the same plaintext letter to different ciphertext letters. Python code is also included to encrypt and decrypt messages using a polyalphabetic cipher.

Uploaded by

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

Name: Rhugved Satardekar

Roll No: 17141208

Experiment No: 7

Aim: Implement and write advantages of Poly-alphabetic Cipher.

Theory:

Poly-alphabetic Cipher:

In a polyalphabetic cipher, multiple cipher alphabets are used. To facilitate encryption, all the
alphabets are usually written out in a large table, traditionally called a tableau. Usually the
tableau is 26 × 26, so that 26 full ciphertext alphabets are available. The method of filling the
tableau, and of choosing which alphabet to use next, defines the particular polyalphabetic
cipher. All such ciphers are easier to break than were believed since the substitution alphabets
are repeated for sufficiently large plaintexts. One of the most popular was that of Vigenere
cipher. A simple substitution cipher involves a single mapping of the plaintext alphabet onto
ciphertext characters (Menezes et al 1997). A more complex alternative is to use different
substitution mappings (called multiple alphabets) on various portions of the plaintext. This
results in so-called polyalphabetic substitution. In the simplest case, the different alphabets
are used sequentially and then repeated, so the position of each plaintext character in the
source string determines which mapping is applied to it. Under different alphabets, the same
plaintext character is thus encrypted to different ciphertext characters, precluding simple
frequency analysis as per monoalphabetic substitution. The simple Vigenere cipher is a
polyalphabetic substitution cipher. The definition is repeated here for convenience.

A polyalphabetic cipher is any cipher based on substitution, using multiple substitution


alphabets. The Vigenère cipher is probably the best-known example of a polyalphabetic
cipher, though it is a simplified special case. Polyalphabetic Cipher is described as
substitution cipher in which plain text letters in different positions are enciphered using
different cryptoalphabets.

A stream cipher is a polyalphabetic cipher if the value of id does depend on the position of
the plain text character in the plain text stream. Each alphabetic character of plain text can be
mapped onto ‘m’ alphabetic characters of a cipher text. The relationship between a character
in the plain text and the characters in the cipher text is one-to-many.

VIGENERE ` CIPHER:

The best known, and one of the simplest, polyalphabetic ciphers is the Vigenère cipher. In
this scheme, the set of related monoalphabetic substitution rules consists of the 26 Caesar
ciphers with shifts of 0 through 25. Each cipher is denoted by a key letter, which is the
ciphertext letter that substitutes for the plaintext letter a. Thus, a Caesar cipher with a shift of
3 is denoted by the key value . We can express the Vigenère cipher in the following manner.
Assume a sequence of plaintext letters and a key consisting of the sequence of letters , where
typically < .The sequence of ciphertext letters is calculated as follows: Thus, the first letter of
the key is added to the first letter of the plaintext, mod 26, the second letters are added, and so
on through the first letters of the plaintext. For the next letters of the plaintext, the key letters
are repeated. This process continues until all of the plaintext sequence is encrypted.

Advantages of Poly-alphabetic Cipher:

The advantage of Polyalphabetic ciphers is that they make frequency analysis more difficult.
Frequency analysis is the practice of decrypting a message by counting the frequency of
ciphertext letters, and equating it to the letter frequency of normal text. For instance if P
occurred most in a ciphertext whose plaintext is in English, one could suspect that P
corresponded to E, because E is the most frequently used letter in English. Using the
Vigenere cipher, E can be enciphered as any of several letters in the alphabet in the Vigenere
cipher, thus defeating simple frequency analysis .

Program:
import math
import time
import random

encrypt_letter_to_num =
{"a":0,"b":1,"c":2,"d":3,"e":4,"f":5,"g":6,"h":7,"i":8,"j":9,"k":10,"l":11,"m":12,"n":13,"o":14,
"p":15,"q":16,"r":17,"s":18,"t":19,"u":20,"v":21,"w":22,"x":23,"y":24,"z":25,"'":26,",":27,".":
28,"?":29,"/":30," ":31}
encrypt_num_to_letter =
{0:"a",1:"b",2:"c",3:"d",4:"e",5:"f",6:"g",7:"h",8:"i",9:"j",10:"k",11:"l",12:"m",13:"n",14:"o",
15:"p",16:"q",17:"r",18:"s",19:"t",20:"u",21:"v",22:"w",23:"x",24:"y",25:"z",26:"'",27:",",28:
".",29:"?",30:"/",31:" "}

while True:
en_de = ""
en_de = input("Would you like to encrypt a message or decrypt a message?[e/d]: ").lower()

if en_de == "e":
displacement_word = input("Please enter your displacement word: ")
main_body = (input("Please input your message, all cases will be changed to lower:
")).lower()

new_word = ""

displacement_list = []
for x in displacement_word:
displacement_list.append(encrypt_letter_to_num[x])

displacement_list_position_count = 0

for x in main_body:
if displacement_list_position_count == len(displacement_list):
displacement_list_position_count = 0
old_value = encrypt_letter_to_num[x]
new_value = old_value + displacement_list[displacement_list_position_count]
while new_value > 31:
new_value -= 32
new_word += encrypt_num_to_letter[new_value]
displacement_list_position_count += 1

print(new_word)

if en_de == "d":
displacement_word = input("Please enter your displacement word: ")
main_body = (input("Please input your message, all cases will be changed to lower:
")).lower()

new_word = ""

displacement_list = []
for x in displacement_word:
displacement_list.append(encrypt_letter_to_num[x])

displacement_list_position_count = 0

for x in main_body:
if displacement_list_position_count == len(displacement_list):
displacement_list_position_count = 0
old_value = encrypt_letter_to_num[x]
new_value = old_value - displacement_list[displacement_list_position_count]
while new_value < 0:
new_value += 32
new_word += encrypt_num_to_letter[new_value]
displacement_list_position_count += 1

print(new_word)

Output:
Conclusion: Thus we have studied how to Implement and write advantages of Poly-
alphabetic Cipher.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy