or you could simply use
Code:
std::getline(std::cin, plainText);
//or
std::getline(std::cin, plainText, '\n');
He is a simple function to use XOR to encrypt a file, all you have to do is hardcode your key
Code:
struct CRYPT_
{
char* byte;
std::string key;
};
//here is the function
CRYPT_ data;
bool Crypt(const std::string& file)
{
data.byte = new char;
char* savebyte = new char;
int value = 0;
data.key = "!+_@)#($*%&^-=,./'\"][}{|:\\<>?~`";
ifstream load (file.c_str(), ios::binary);
if (!load)
{
return false;
}
ofstream save ("encrypted.xtc", ios::binary);
while (load.get(*data.byte))
{
*savebyte = *data.byte ^ data.key[value];
save << *savebyte;
if ( value < 30 )
{
++value;
}
else
{
value = 0;
}
}
save.close();
load.close();
remove(file.c_str());
rename("encrypted.xtc", file.c_str());
delete data.byte;
delete savebyte;
return true;
}
I hope that helps. It is a relatively basic function, but easy to complicate more if you needed.