Create an encryption program a Create a program with two opt

Create an encryption program a) Create a program with two options (encryption and decryption) b) The user will input a message (max 50 character long) c) The program will show the encrypted or decrypted file to the user and in a txt file called message.txt d) The user need to clearly explain the encryption and decryption process

Solution

/**
C ++ program that describes the encryption process of files.
The program open a text file that contains the plain text.
Then the program opens and read a text file lines.txt
and encrypt the file lines.txt with password and save
to linesEncrypt.txt file and decrypt the files
using encryption file using the password
and save to linesDecrypted.txt file
*/
#include<iostream>
#include<fstream>
#include<string>
using namespace std;
void encryptFileContent(ifstream &inputFileName, int encodeValue, ofstream &outputFileName);
void decryptFileContent(ifstream &encryptedFileName, int encodeValue, ofstream &decryptedFileName);
int main()
{
   char inputFileName[20]=\"lines.txt\";
   int password = 10;
   char outputFileName[20]=\"linesEncrypt.txt\";
   char decryptFileName[20]=\"linesDecrypted.txt\";

   ifstream inputFile;
   inputFile.open(inputFileName);

   ofstream encryptFile;
   encryptFile.open(outputFileName);

   encryptFileContent(inputFile, password,encryptFile);  


   inputFile.close();
   encryptFile.close();
  
   inputFile.open(outputFileName);

   ofstream decryptFile;
   decryptFile.open(decryptFileName);

   decryptFileContent(inputFile, password,decryptFile);
  
   inputFile.close();
   decryptFile.close();

}

void encryptFileContent(ifstream &inputFileName, int encodeValue, ofstream &outputFileName)
{
   char data;
   while(inputFileName>>data)
   {          
       outputFileName<<char(data+encodeValue);
   }
}
void decryptFileContent(ifstream &encryptedFileName, int encodeValue, ofstream &decryptedFileName)
{
   char data;
   while(encryptedFileName>>data)
   {      
      
       decryptedFileName<<char(data-encodeValue);
   }
}


--------------------------------------------------------

lines.txt

helloword.This is c++ programming.

------------------------------------------------------

Sample Output:

linesEncrypt.txt

rovvyy|n8^rs}s}m55z|yq|kwwsxq8

linesDecrypted.txt

helloword.Thisisc++programming.

 Create an encryption program a) Create a program with two options (encryption and decryption) b) The user will input a message (max 50 character long) c) The p
 Create an encryption program a) Create a program with two options (encryption and decryption) b) The user will input a message (max 50 character long) c) The p

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site