Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

AFFINE CIPHER You will need to write a utility for encrypting, decrypting, and deciphering ASCII text documents using an affine cipher. Encryption function E(m, a,

AFFINE CIPHER

You will need to write a utility for encrypting, decrypting, and deciphering ASCII text documents using an affine cipher.

Encryption function E(m, a, b) = (am + b) mod 128.

1) The utility must accept a first command line parameter that is either encrypt, decrypt, or decipher.

2) The utility must accept a second command line parameter that is a path to an ASCII input file. For encrypting this file will be a plain text file, while for decrypting it will be a cipher text file.

4. The utility must accept a third command line parameter that is a path to an ASCII output file (that the utility will write). For encrypting the file will be a cipher file, while

for decrypting or deciphering it will be a plain text file.

5. The utility must accept a fourth and fifth parameter if its first parameter is either encrypt or decrypt. These parameters will consist of integers a and b designating the affine cipher multiplier and increment parameters, respectively.

6. The utility must accept a fourth parameter if its first parameter is decipher. This parameter is a pathname to a dictionary file used to break the affine cypher.

7. If the first parameter to the utility is encrypt or decrypt, and the pair of integers (a, b) is a valid encryption key, the utility must encrypt or decrypt the text in the input file and write the result to the output file.

8. If the first parameter to the utility is encrypt or decrypt, and the pair of integers (a, b) is not a valid encryption key, the utility must neither read an input file nor write an output file, but instead must print the following message on the standard output stream (with the user-supplied values for a and b in place of and ).

The key pair (, ) is invalid, please select another key.

9. If the first parameter to the utility is decipher, then the utility must read the input file and dictionary file and attempt to decrypt the input file by trying each valid pair (a, b) as a decryption key for an affine cypher. The utility must break the resulting plain text into words and then count the number of valid words in the plain text. A word is valid if it is contained in the dictionary. The plain text with the most valid words must be considered the deciphered text. The utility must write the following data to its output file.

- The the key pair used to decrypt the deciphered text (a, b) in the format " " on the first line of the output file. In other words, a and b appear as the first line of the

output file, separated by a space.

- A line with the text "DECRYPTED MESSAGE:". In other words, these words are the second line of the output file.

- The decrypted message, occupying as many lines as it needs.

10.The dictionary file must contain words, one per line, in lowercase.

Can code in any language. Need to pass command line arguments to Encrypt and Decrypt.

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

Students also viewed these Databases questions