Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

can someone help me write a decryption code for this code #include //just for writing and reading from console #include //this one to deal with

can someone help me write a decryption code for this code

#include

//just for writing and reading from console

#include

//this one to deal with files, read and write to text files

using namespace std;

int main()

{

//first thing we need to read the data in the text file

//let's assume we have the reading in a text file called data.txt

//so, we need a stream input variable to hold this data

ifstream infile;

//now we copy the data from the file into this variable

infile.open("data.txt");

//now we have the text copied to this stream

//first thing we need to check if the file is open or not

if(!infile.eof())

//

{

cout<<"Error opening the file.";

return -1; //this line will end the program

}

//here we need to open the file that we will print

//the output to, that is the encrypted file

ofstream outfile;

outfile.open("out.txt"); //this will create an out file to write in later

//here we need to make a loop to change each character in the file

string line; //this will hold the string in each line in the infile

while(outfile.getline(line)) //this statement copies data

{

//here we make the encryption on the line, and then print it back into

//the output file

for(int i=0;i

{

line[i] += 3;

}

//now the line has been encrypted

//we pass it to the out file

outfile<

}

//now we close both files

infile.close();

outfile.close();

}

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

Database Systems For Advanced Applications Dasfaa 2023 International Workshops Bdms 2023 Bdqm 2023 Gdma 2023 Bundlers 2023 Tianjin China April 17 20 2023 Proceedings Lncs 13922

Authors: Amr El Abbadi ,Gillian Dobbie ,Zhiyong Feng ,Lu Chen ,Xiaohui Tao ,Yingxia Shao ,Hongzhi Yin

1st Edition

3031354141, 978-3031354144

More Books

Students also viewed these Databases questions