Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I understand this problem is long, but if you could atleast help me get started I would appreciate that. PROGRAM DESCRIPTION: The purpose of this

I understand this problem is long, but if you could atleast help me get started I would appreciate that.

PROGRAM DESCRIPTION:

The purpose of this programming project is to write a C++ program to implement a simple stream cipher that incorporates topics related to file I/O. In particular, this programming assignment will read an input file, encrypt or decrypt the file based on the requested operation, and write the results to an output file.

image text in transcribed

Please provide a clean code, with comments, as I will give you a great rating if you have clean and correct code.

In your main0 function, you will prompt the user whether he/she would like to encrypt or decrypt a file. If a valid response is not input, you are to repeatedly reprompt the user until a valid response is input. Also inside your main) function, you will then prompt the user to enter the name of the input file to read from and the output file to write the resulting plaintext or ciphertext as appropriate. You will attempt to open both files in your main0 function. If there is a problem opening the file, you will display a meaningful error and exit the program using the appropriate exit status. You may assume that the length of the file name does not exceed 32 characters (33 with the terminating null character) If there are no errors causing you to terminate the program at this point, you will then call the encryption or decryption function that will process the input file and write the results to an output file. The files that you will encrypt or decrypt can contain uppercase alphabetic characters (A - Z), lowercase alphabetic characters (a- z), digits (0-9), punctuation, and whitespace, which may include any white space character such as a blank space, a tab, or a newline character The user-defined functions to process the input and output files (i.e., to encrypt and decrypt) should accept two parameters as a minimum, the input file stream and the output file stream, but it may utilize additional parameters as needed. You must process each file character-by-character (i.e. using the get and put member functions). You will handle encryption in the following manner: You will prompt the user to enter the name of a different file that will contain your encryption keys. You will attempt to open the file in this function. If there is a problem opening the file, you will display a meaningful error and exit the program using the appropriate exit status. You may assume that the length of the file name does not exceed 32 characters (33 with the terminating null character). Any randomly generated keys for alphabetic characters and digits will be written to this file (that will later be used in decryption). Be sure to close the key file when you are done. You will encrypt all alphabetic characters, both uppercase and lowercase, as well as all digit characters using a randomly generated integral value between 3 and 277, inclusively. Be sure to seed your random number. Uppercase characters should encrypt to uppercase characters, lowercase characters to lowercase characters, and digits to digits. For example, if the key is 3, A would be replaced with the D, B would be replaced by E, ..., Y would be replaced by B, and Z would be replaced by C Similarly, if the key is 3, a would be replaced with the d, b would be replaced by e,.. y would be replaced by b, and z would be replaced by c. Additionally, if the key is 3, 0 would be replaced by 3, 1 would be replaced by 4, 8 would be replaced by 1, and 9 would be replaced by 2 . a. b. c. If a punctuation character is read in, you will not encrypt the character, but simply keep the punctuation character as is and write it to the ciphertext file. This means that you will not generate a key for punctuation characters. If a whitespace character is read in, such as a blank space, a tab, or a newline character, you will not encrypt the whitespace character, but simply discard and not write it to the ciphertext file. This means that you will not generate a key for whitespace d. e. Any other characters not included in the above description shall be ignored (i.e., discarded), but an error message will be displayed and encryption should continue. All encrypted and punctuation characters based on these requirements will be written to the ciphertext file specified by the user f. 2. You will handle decryption in the following manner: a. You will prompt the user to enter the name of the file that contains your encryption keys. You will attempt to open the file in this function. If there is a problem opening the file, you will display a meaningful error and exit the program using the appropriate exit status. You may assume that the length of the file name does not exceed 32 characters (33 with the terminating null character). you will use this file to read the randomly generated keys for alphabetic characters and digits in the encryption process. Be sure to close the key file when you are done. You ll decrypt all alphabetic characters, both uppercase and lowercase, as well as all digits, using the correct randomly generated key for each encrypted character. Uppercase characters should decrypt to uppercase characters, lowercase characters to lowercase characters, and digits to digits. For example, if the key is 3, D would be replaced with the A, E would be replaced by B B would be replaced by Y, and C would be replaced by Z. Similarly, if the key is 3, d would be replaced with the a, e would be replaced by b,..., b would be replaced by y, and c would be replaced by z. And finally, if the key is 3, 3 would be replaced by 0, 4 would be replaced by 1, ..., 1 would be replaced by 8, and 2 would be replaced by 9. It is important that the key used to encrypt this file is the SAME key that is used to decrypt the file, or you will not get the expected results. e. If the ciphertext file contains punctuation, you will do no decryption, but simply keep the punctuation character as is and write it to d. Any other characters not included in the above description shall be ignored (i.e., discarded), but an error message will be displayed e. All decrypted, and punctuation characters based on these requirements will be written to the plaintext file specified by the user Be sure to close both the input and output file after you are done processing them In your main0 function, you will prompt the user whether he/she would like to encrypt or decrypt a file. If a valid response is not input, you are to repeatedly reprompt the user until a valid response is input. Also inside your main) function, you will then prompt the user to enter the name of the input file to read from and the output file to write the resulting plaintext or ciphertext as appropriate. You will attempt to open both files in your main0 function. If there is a problem opening the file, you will display a meaningful error and exit the program using the appropriate exit status. You may assume that the length of the file name does not exceed 32 characters (33 with the terminating null character) If there are no errors causing you to terminate the program at this point, you will then call the encryption or decryption function that will process the input file and write the results to an output file. The files that you will encrypt or decrypt can contain uppercase alphabetic characters (A - Z), lowercase alphabetic characters (a- z), digits (0-9), punctuation, and whitespace, which may include any white space character such as a blank space, a tab, or a newline character The user-defined functions to process the input and output files (i.e., to encrypt and decrypt) should accept two parameters as a minimum, the input file stream and the output file stream, but it may utilize additional parameters as needed. You must process each file character-by-character (i.e. using the get and put member functions). You will handle encryption in the following manner: You will prompt the user to enter the name of a different file that will contain your encryption keys. You will attempt to open the file in this function. If there is a problem opening the file, you will display a meaningful error and exit the program using the appropriate exit status. You may assume that the length of the file name does not exceed 32 characters (33 with the terminating null character). Any randomly generated keys for alphabetic characters and digits will be written to this file (that will later be used in decryption). Be sure to close the key file when you are done. You will encrypt all alphabetic characters, both uppercase and lowercase, as well as all digit characters using a randomly generated integral value between 3 and 277, inclusively. Be sure to seed your random number. Uppercase characters should encrypt to uppercase characters, lowercase characters to lowercase characters, and digits to digits. For example, if the key is 3, A would be replaced with the D, B would be replaced by E, ..., Y would be replaced by B, and Z would be replaced by C Similarly, if the key is 3, a would be replaced with the d, b would be replaced by e,.. y would be replaced by b, and z would be replaced by c. Additionally, if the key is 3, 0 would be replaced by 3, 1 would be replaced by 4, 8 would be replaced by 1, and 9 would be replaced by 2 . a. b. c. If a punctuation character is read in, you will not encrypt the character, but simply keep the punctuation character as is and write it to the ciphertext file. This means that you will not generate a key for punctuation characters. If a whitespace character is read in, such as a blank space, a tab, or a newline character, you will not encrypt the whitespace character, but simply discard and not write it to the ciphertext file. This means that you will not generate a key for whitespace d. e. Any other characters not included in the above description shall be ignored (i.e., discarded), but an error message will be displayed and encryption should continue. All encrypted and punctuation characters based on these requirements will be written to the ciphertext file specified by the user f. 2. You will handle decryption in the following manner: a. You will prompt the user to enter the name of the file that contains your encryption keys. You will attempt to open the file in this function. If there is a problem opening the file, you will display a meaningful error and exit the program using the appropriate exit status. You may assume that the length of the file name does not exceed 32 characters (33 with the terminating null character). you will use this file to read the randomly generated keys for alphabetic characters and digits in the encryption process. Be sure to close the key file when you are done. You ll decrypt all alphabetic characters, both uppercase and lowercase, as well as all digits, using the correct randomly generated key for each encrypted character. Uppercase characters should decrypt to uppercase characters, lowercase characters to lowercase characters, and digits to digits. For example, if the key is 3, D would be replaced with the A, E would be replaced by B B would be replaced by Y, and C would be replaced by Z. Similarly, if the key is 3, d would be replaced with the a, e would be replaced by b,..., b would be replaced by y, and c would be replaced by z. And finally, if the key is 3, 3 would be replaced by 0, 4 would be replaced by 1, ..., 1 would be replaced by 8, and 2 would be replaced by 9. It is important that the key used to encrypt this file is the SAME key that is used to decrypt the file, or you will not get the expected results. e. If the ciphertext file contains punctuation, you will do no decryption, but simply keep the punctuation character as is and write it to d. Any other characters not included in the above description shall be ignored (i.e., discarded), but an error message will be displayed e. All decrypted, and punctuation characters based on these requirements will be written to the plaintext file specified by the user Be sure to close both the input and output file after you are done processing them

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_2

Step: 3

blur-text-image_3

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

Database Programming Languages 12th International Symposium Dbpl 2009 Lyon France August 2009 Proceedings Lncs 5708

Authors: Philippa Gardner ,Floris Geerts

2009th Edition

3642037925, 978-3642037924

More Books

Students also viewed these Databases questions

Question

a. How do you think these stereotypes developed?

Answered: 1 week ago

Question

7. Describe phases of multicultural identity development.

Answered: 1 week ago