Question: Write a C + + program that reads text from a file and encrypts the file by adding an encryption factor ( EF ) to

Write a C++ program that reads text from a file and encrypts the file by adding an encryption factor (EF) to the ASCII value of each character. The encryption factor is 1 for the first line and increases by 1 for each line up to 6 and then starts over at 1. So, for the 6th line the EF is 6, for the 7th line it is 1, for the 10th line it is 4. In General, for the Nth line, the encryption factor is (N -1)%6+1.If the seventh line of the input file is, This is the seventh line of the file. The seventh line of the encrypted file would have 1 added to each character. It would look like, Uijt!jt!uif!tfwfoui!mjof!pg!uif!gjmf/1. Read the provided plain-1.txt file one line at a time. Because this file has spaces, use getline.2. Change each character of the string by adding the encryption factor to it.3. Write the encoded string to a second file, such as coded.txt4. The encoded file should have the same structure as the original file, if the second line of the original file has 24 characters (including spaces) then there should be 24 characters on the second line of the encoded file (spaces will now be replaced by the characters !,, #,$,%,&).

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!