Here is the updated code with encryption algorithm:
#include<iostream>
#include<string>
#include<fstream>
int main()
{
char ch;
char cch[128];
char pch[128];
std::string str;
std::string key = "01100011 01100001 01110100";
std::fstream pFile;
std::fstream cFile;
pFile.open("plaintext.txt", std::ios::in);
if (pFile.is_open())
{
//Use the key to encrypt the plain text.
for(int i=0; i<str.size(); i++)
cch[i] = (pch[i] ^ key[i]) % key.size();
}
else
{
std::cout<<"Error!"<<std::endl;
pFile.close();
}
cFile.open("ciphertext.txt", std::ios::binary | std::ios::out);
while (pFile.get(ch))
{
cFile.put(ch);
}
pFile.close();
cFile.close();
return 0;
}
I still get the original text in the cipher text file. The problems I am having is I do not know how to get the plain text into binary so I can xor it using the key and I am not exactly sure where to place the encryption algorithm in the code. I also understand what people are saying about str being empty, but I do not know what to do to fix that.