Question
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
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