i am currently working on a program whereby i can substitute alphabets in a text file(called plaintext.txt), along with a keyfile, and create a ciphertext when i run a command to mix them together. The working code is as shown below:
string text;
string cipherAlphabet;
string text = "hello";
string cipherAlphabet = "yhkqgvxfoluapwmtzecjdbsnri";
string cipherText;
string plainText;
bool encipherResult = Encipher(text, cipherAlphabet, cipherText);
bool decipherResult = Decipher(cipherText, cipherAlphabet, plainText);
cout << cipherText;
cout << plainText;
Output for the above code will be below
fgaam
hello
However, i want to convert my "text" and "cipherAlphabet" into a string where i obtain the both of them through different text files.
string text;
string cipherAlphabet;
std::ifstream u("plaintext.txt"); //getting content from plainfile.txt, string is text
std::stringstream plaintext;
plaintext << u.rdbuf();
text = plaintext.str(); //to get text
std::ifstream t("keyfile.txt"); //getting content from keyfile.txt, string is cipherAlphabet
std::stringstream buffer;
buffer << t.rdbuf();
cipherAlphabet = buffer.str(); //get cipherAlphabet;*/
string cipherText;
string plainText;
bool encipherResult = Encipher(text, cipherAlphabet, cipherText);
bool decipherResult = Decipher(cipherText, cipherAlphabet, plainText);
cout << cipherText;
cout << plainText;
However if i do this, i get no output and no error? Is there anyone out there that can help me with this please? Thank you!!