PYTHON: In order to defeat a simple letter frequency analysis, the Vigenère cipher encodes a letter into one of several

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

PYTHON: In order to defeat a simple letter frequency analysis, the Vigenère cipher encodes a letter into one of several

Post by answerhappygod »

PYTHON: In order to defeat a simple letter frequency analysis,
the Vigenère cipher encodes a letter into one of several cipher
letters, depending on its position in the input document. Choose a
keyword, for example TIGER. Then encode the first letter of the
input text like this:
Python In Order To Defeat A Simple Letter Frequency Analysis The Vigenere Cipher Encodes A Letter Into One Of Several 1
Python In Order To Defeat A Simple Letter Frequency Analysis The Vigenere Cipher Encodes A Letter Into One Of Several 1 (272.9 KiB) Viewed 25 times
The third, fourth, and fifth letters in the input text are
encrypted using the alphabet sequences beginning with characters G,
E, and R, and so on. Because the key is only five letters long, the
sixth letter of the input text is encrypted in the same way as the
first. Write a Python program that encrypts or decrypts an input
text file according to this cipher. Your program takes the
following command line arguments:
• A keyword, such as TIGER, to indicate the encoding
• An optional -d flag to indicate decryption instead of
encryption
• The input file name
• The output file name
For example, python cipher.py FOOBAR input.txt encrypt.txt
encrypts the file input.txt and places the result into the file
encrypt.txt, using an encryption key of FOOBAR; whereas python
cipher.py FOOBAR -d encrypt.txt output.txt decrypts the file
encrypt.txt and places the result into output.txt. Note that your
encryption/decryption functions should only work on uppercase
alphabetic characters.
A B C D E F G H I J K L M N 0 Р 0. R S T U V W X Y Z T U V W X Y Z A B C D E F G H I J K L M N O P Q R S G 0 The encoded alphabet is just the regular alphabet shifted to start at T, the first letter of the keyword TIGER. The second letter is encrypted according to the following map. A B C D E F G H I J K L M N O P Q R S T U V W X Y Z I J K L M N O L M N † Ù Ÿ W X Y Z A B C D E F P Q R S A G H
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply