Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In basic C++ please. In this program you will have to take the input from a file (input the file name to read from). The

In basic C++ please.

In this program you will have to take the input from a file (input the file name to read from). The input will be encrypted using the Caesar cipher.

The Caesar cipher works by shifting every letter up by the key (an integer between 1-25). For example, given a letter 'c' and a key 5, the encrypting process will shift 'c' to 'h' (i.e., five positions after 'c' in the alphabet). Hence, when decrypting you should think about the inverse operation of encrypting (shifting down every letter by the key).

The program will receive three inputs from the user via keyboards: Filename, Decryption Key, Encryption Key.

All characters in the text will be lower-case. (The ASCII values for a - z are from 97 (a) to 122 (z).)

(1) Load the encrypted message (that may contain multiple lines) and output it on to screen. If the file does not exist, print out File not found. and end the program.

(2) Decrypt the text using the decryption key.

(3) Encrypt the decrypted text (found in step 2) with the encryption key.

Hint: To achieve shifting of the letter, increase or decrease the ASCII value of a character by the key. Ensure that the characters wrap around (for encrypting, after 'z', it should wrap to 'a'; similarly, for decrypting, after 'a', it should wrap to 'z').

Your program should ignore all the non-lower case letters (i.e., characters whose ASCII values are not in the range of [97, 122]).

Example:

Input:

input1.txt 1 6 

input1.txt:

ifmmp ns.cpoe, xf ibwf uif qbznfou sfbez gps uif fydibohf. 

Output

  • send the decrypted message to file "decrypted.txt". Given the above input, after running the program, it will contain:
hello mr.bond, we have the payment ready for the exchange. 
  • send the re-encrypted message to the file "encrypted.txt". Given the above input, after running the program, it will contain:
nkrru sx.hutj, ck ngbk znk vgesktz xkgje lux znk kdingtmk.

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

MySQL/PHP Database Applications

Authors: Brad Bulger, Jay Greenspan, David Wall

2nd Edition

0764549634, 9780764549632

More Books

Students also viewed these Databases questions

Question

Simplify each complex fraction. 1. 2. 3. 4. 3 3 14 4, 4.

Answered: 1 week ago

Question

1. Identify the sources for this conflict.

Answered: 1 week ago

Question

3. How would you address the problems that make up the situation?

Answered: 1 week ago

Question

2. What recommendations will you make to the city council?

Answered: 1 week ago