Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

All code should be in Python 3. Use this alphabet abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890`~!@#$%^&*()-_=+[]{}|;:',./ ? t *(the last character is a space)* Use row matrices to encrypt

All code should be in Python 3.

Use this alphabet "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890`~!@#$%^&*()-_=+[]{}\\|;:\'",./<>? \t " *(the last character is a space)*

Use row matrices to encrypt and decrypt.

The encryption portion of your program starts by asking for a key. If an invalid key is entered the program displays an error message and terminates.

The encryption portion needs to know the name of the file containing the plain text message and the name of file where the encrypted message will be saved. Your program should prompt the user for these file names and check to see if they exist. If the input file does not exist, the program should display an error message and terminate. If the output file already exists, the program should ask the user if they are sure they want to overwrite it.

See the below sample runs to get an idea of how the encryption program should run.

The Decryption portion of your program starts by asking for a key. If an invalid key is entered the program displays an error message and terminates. The key entered to decrypt a message should be the same key entered to encrypt the message.

The decryption portion needs to know the name of the file containing the encrypted message and the name of file where the decrypted message will be saved. Your program should prompt the user for these file names and check to see if they exist. If the input file does not exist, the program should display an error message and terminate. If the output file already exists the program should ask the user if they are sure they want to overwrite it.

See the below sample runs to get an idea of how the encryption program should run.

Sample Runs

Below are several sample runs that show how your program should operate.

What would you like to do:

 1) Encrypt a file 2) Decrypt a file Selection: 4 Invalid Selection 
 What would you like to do: 1) Encrypt a file 2) Decrypt a file Selection: 1 A key consists of 4 integers: a, b, c, and d. Enter a: 1 Enter b: 2 Enter c: 3 Enter d: 4 Invalid key 
 What would you like to do: 1) Encrypt a file 2) Decrypt a file Selection: 1 A key consists of 4 integers: a, b, c, and d. Enter a: 5 Enter b: 2 Enter c: 3 Enter d: 1 Enter the name of the file to encrypt: badName.txt File "badName.txt" does not exist 
 What would you like to do: 1) Encrypt a file 2) Decrypt a file Selection: 1 A key consists of 4 integers: a, b, c, and d. Enter a: 5 Enter b: 2 Enter c: 3 Enter d: 1 Enter the name of the file to encrypt: message1.txt Enter a name for the encrypted file: enc1.txt File "enc1.txt" already exists. Are you sure you want to overwrite it? n 
 What would you like to do: 1) Encrypt a file 2) Decrypt a file Selection: 1 A key consists of 4 integers: a, b, c, and d. Enter a: 5 Enter b: 2 Enter c: 3 Enter d: 1 Enter the name of the file to encrypt: message1.txt Enter a name for the encrypted file: enc1.txt File "enc1.txt" already exists. Are you sure you want to overwrite it? y File "message1.txt" encrypted and saved to "enc1.txt". 
 What would you like to do: 1) Encrypt a file 2) Decrypt a file Selection: 2 A key consists of 4 integers: a, b, c, and d. Enter a: 5 Enter b: 4 Enter c: 3 Enter d: 2 Invalid Key 
 What would you like to do: 1) Encrypt a file 2) Decrypt a file Selection: 2 A key consists of 4 integers: a, b, c, and d. Enter a: 5 Enter b: 2 Enter c: 3 Enter d: 1 Enter the name of the file to decrypt: enczzz.txt File "enczzz.txt" does not exist 
 What would you like to do: 1) Encrypt a file 2) Decrypt a file Selection: 2 A key consists of 4 integers: a, b, c, and d. Enter a: 5 Enter b: 2 Enter c: 3 Enter d: 1 Enter the name of the file to decrypt: enc1.txt Enter a name for the decrypted file: dec1.txt File "dec1.txt" already exists. Are you sure you want to overwrite it? n 
 What would you like to do: 1) Encrypt a file 2) Decrypt a file Selection: 2 A key consists of 4 integers: a, b, c, and d. Enter a: 5 Enter b: 2 Enter c: 3 Enter d: 1 Enter the name of the file to decrypt: enc1.txt Enter a name for the decrypted file: dec1.txt File "dec1.txt" already exists. Are you sure you want to overwrite it? y File "enc1.txt" decrypted and saved to "dec1.txt". 

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional Microsoft SQL Server 2012 Administration

Authors: Adam Jorgensen, Steven Wort

1st Edition

1118106881, 9781118106884

More Books

Students also viewed these Databases questions

Question

Name and briefly describe the five product mix pricing decisions.

Answered: 1 week ago