Question
Programming Requirements You will write a program consisting of the following files: cipher.cpp : Contains your main function, provides all input/output with the user, and
Programming Requirements
You will write a program consisting of the following files:
- cipher.cpp: Contains your main function, provides all input/output with the user, and is responsible for reading the file into a buffer (i.e., a string).
- encrypt.cpp: Contains a function named encrypt, that takes two parameters: (i) a string containing text to encrypt, and an integer for the shift value. The function should declare a string, store the encrypted text in it, and return the string.
- decrypt.cpp: Contains a function named decrypt, that takes two parameters: (i) a string containing text to decrypt, and an integer for the shift value. The function should create a string variable, store the decrypted text in it, and return the string.
- encrypt.h: Contains the function header for the encrypt function. Do not forget your header guard! This file should be included by cipher.cpp.
- decrypt.h: Contains the function header for the decrypt function. Do not forget your header guard! This file should be included by cipher.cpp.
Your program should do the following:
- Ask the user if they want to encrypt or decrypt some text.
- Ask the user for the shift value.
- Ask the user for the file they wish to encrypt/decrypt.
- Perform the encryption or decryption of the file based on the user's input in 1.
- Print the string returned from your encrypt/decrypt function.
Here are some examples of the full run of the program:
Sample Run 1 (sample1-enc.txt)
ranger0$ ./cipher
Would you like to (e)ncrypt or (d)ecrypt a file? e
Enter the shift value: 8
Enter the path to the file: sample1-enc.txt
The encrypted text is:
Twzmu qxacu lwtwz aqb iumb, kwvamkbmbcz ilqxqakqvo mtqb, aml lw mqcauwl bmuxwz qvkqlqlcvb cb tijwzm mb lwtwzm uiovi itqyci. Cb mvqu il uqvqu dmvqiu, ycqa vwabzcl mfmzkqbibqwv cttiukw tijwzqa vqaq cb itqycqx mf mi kwuuwlw kwvamycib. Lcqa icbm qzczm lwtwz qv zmxzmpmvlmzqb qv dwtcxbibm dmtqb maam kqttcu lwtwzm mc ncoqib vctti xizqibcz. Mfkmxbmcz aqvb wkkimkib kcxqlibib vwv xzwqlmvb, acvb qv kctxi ycq wnnqkqi lmamzcvb uwttqb ivqu ql mab tijwzcu.
Sample Run 2 (sample1-dec.txt)
ranger0$ ./cipher
Would you like to (e)ncrypt or (d)ecrypt a file? d
Enter the shift value: 12
Enter the path to the file: sample1-dec.txt
The decrypted text is:
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started