Computers and Technology

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".

answer
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 14:30, ladawnrowles005
The option enables you to modify a slide element in most presentation applications.
Answers: 2
image
Computers and Technology, 24.06.2019 12:40, kanga06
Match the feature to the network architecture. expensive to set up useful for a small organization easy to track files has a central server inexpensive to set up difficult to track files useful for a large organization does not have a central server client- server network peer-to-peer network
Answers: 3
image
Computers and Technology, 24.06.2019 21:40, Jsusussueususu
is on drugs i swear i ask a question and its not showing whats going
Answers: 2
image
Computers and Technology, 25.06.2019 07:10, izearaholland7308
When you “listen” to evaluate an online message, which question should you ask?
Answers: 1
Do you know the correct answer?
For this assignment you will be implementing simple rotation encryption to be used on a text file. Y...

Questions in other subjects:

Konu
Mathematics, 12.12.2020 16:50