subject

For this assignment you will be implementing simple rotation encryption to be used on a text file. Your program will need to read in text from a text file and encrypt or decrypt it (have the user select which) using the encryption key entered by the user, then write the results out to another file. The user will enter the names of the source and destination files, the encryption key, and will select whether they are encrypting or decrypting the file.
Rotation Encryption:
Rotation encryption involves shifting each letter in the encrypted passage forward by the amount of the encryption key. For example, if the string to encrypt is "Apple" and the encryption key is 2, the encrypted result is "Crrng". Decryption reverses the process by shifting each letter backward by the amount of the encryption key, so "Crrng" decrypts back to "Apple". Note that if someone were to have a copy of an encrypted file and your program, they could recover the original contents only if they also knew the encryption key (while this encryption could easily be "brute-forced," i. e. all possible encryption keys could be tried, real world encryption methods have many more possible encryption keys and decryption is a longer process, making this impractical).
Some notes for our implementation:
We will only be encrypting alphabetical characters, i. e. AZ and a-z. Any nonalphabetical characters should be skipped over and kept as-is by the encryption and decryption functions.
We will maintain case when encrypted, i. e. lowercase letters will remain lowercase and uppercase letters will remain uppercase.
If a character would encrypt or decrypt past the ends of AZ or a-z (i. e. beyond Z/z when encrypting or before A/a when decrypting) we will wrap it around to the other end (i. e. with encryption key 3, Y encrypts to B and decrypts back to Y, and y encrypts to b and decrypts back to y).
Your program should be split into functions. At a minimum, the following four functions must be implemented, though you may use others if desired:
A function that reads from a file (takes a single string parameter for the filename and returns a string).
A function that writes to a file (takes 2 string parameters, one for the filename and one for the contents to be written, return type of void).
A function that performs encryption (takes a string parameter for the string to be encrypted and an int parameter for the encryption key, returns the encrypted result as a string).
A function that performs decryption (takes a string parameter for the string to be encrypted and an int parameter for the encryption key, returns the decrypted result as a string).
Hint: Encryption and decryption are very similar – you might want to have your encryption function call your decryption function or vice versa, or write a third function that encryption and decryption both call in order to avoid repetition.
Note: Main should handle all user input. The encrypted or decrypted result is written to a file. Acceptable encryption keys are in the range 1-25 inclusive, you must validate the user’s entered encryption key and if it is out of range require that they re-enter it.
Submit the following to Cougar Courses:
Your code (all .cpp or .C file(s), and any .h files if applicable)
Screenshot(s) of your program having been compiled and then running on empress, including the compilation line (g++ …)
Contents of a sample file, before encryption, after encryption, and after decryption. (note: before and after should match if your program works properly). Save these as 3 text files, "original. txt", "encrypted. txt" and "decrypted. txt".

ansver
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 12:30, pollo44
Antifreeze is not considered a hazardous waste by the epa unless it is used or otherwise becomes contaminated. true or false?
Answers: 1
image
Computers and Technology, 22.06.2019 00:00, azainababbas
Sam is a data analyst at an advertising firm. he often uses a spreadsheet that contains media ratings details. he would like to filter the spreadsheet data based on different filter criteria. which operators can he use to specify the combination of filter criteria? sam can use the ( blank ) operators to specify a combination of filter criteria.
Answers: 3
image
Computers and Technology, 23.06.2019 00:30, lilobekker5219
Knowing that the central portion of link bd has a uniform cross sectional area of 800 mm2 , determine the magnitude of the load p for which the normal stress in link bd is 50 mpa. (hint: link bd is a two-force member.) ans: p = 62.7 kn
Answers: 2
image
Computers and Technology, 23.06.2019 09:10, djs1671
(328 inc. 448 ind. 480 in25. john has a collection of toy cars. he has 2 red cars, 4 blue cars, 4 black cars, and 6 yellowcars. what is the ratio of red cars to yellow cars? a. 1: 2b. 1: 3c. 1: 626. the net of a right triangular prism is shown below.
Answers: 2
You know the right answer?
For this assignment you will be implementing simple rotation encryption to be used on a text file. Y...

Questions in other subjects: