I'm having a problem understanding what this problem wants me to do and what encrypt and decrypt are? Can anyone help please!
1. A function char EncChar (char C, int j, int flag) to receive a character (C) and its index (j) in the message. If flag = 0, the character is plain and we intend to encrypt it. In this case, the function returns the encrypted character by adding a displacement di obtained from a character Ki in a secret key in the form of a string of length (n) characters.
2. A function void encfile (string infile, string outfile) to encrypt/decrypt a whole text file of characters and write the result to another file. This function will call the character function EncChar for each input character.
3. A main function to:
• receive the input and output file names from the user.
• Set a flag = 0 to encrypt and flag = 1 to decrypt.
• Call the file encryption function encfile.
#include <iostream>
#include <string>
usingnamespace std;
constint ENCRYPT = 0;
constint DECRYPT = 1;
int UserOption;
char EncChar (char C, int j, int flag);
void encfile (string infile, string outfile);
void GetFileNames (string &infile, string &outfile);
void GetOption ();
int main ()
{
string infile, outfile;
GetFileNames (infile, outfile);
GetOption ();
encfile (infile, outfile);
system ("pause");
return 0;
}
char EncChar (char C, int j, int flag)
{
// TODO encode the char c and return it
return C;
}
void encfile (string infile, string outfile)
{
// TODO encode od decode infile depending on the global var UserOption
}
void GetFileNames (string &infile, string &outfile)
{
// TODO get the filenames for infile and outfile from the user
// and store them in infile and outfile
}
void GetOption ()
{
// TODO ask the user if he want's to encode or decode thefile
// and store the choice in UserOption
}
Thank you for your help! Just one more question so I make sure that I understand right: The user will give me a string for example "hello" and i have to return it as "elohl" or other way around, right?