Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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:

  1. 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).
  2. 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.
  3. 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.
  4. encrypt.h: Contains the function header for the encrypt function. Do not forget your header guard! This file should be included by cipher.cpp.
  5. 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:

  1. Ask the user if they want to encrypt or decrypt some text.
  2. Ask the user for the shift value.
  3. Ask the user for the file they wish to encrypt/decrypt.
  4. Perform the encryption or decryption of the file based on the user's input in 1.
  5. 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

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

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

Advances In Databases And Information Systems 25th European Conference Adbis 2021 Tartu Estonia August 24 26 2021 Proceedings Lncs 12843

Authors: Ladjel Bellatreche ,Marlon Dumas ,Panagiotis Karras ,Raimundas Matulevicius

1st Edition

3030824713, 978-3030824716

More Books

Students also viewed these Databases questions