I'm using the Botan library for encryption within Qt. I have it working to where I can encrypt and decrypt from one file to another, but I'm trying to alter it to encrypt from a file to a QDomDocument (encrypted file will just be an XML file), and decrypt back from a QDomDocument to a file.
This is what I have so far for the actual encryption (filePlainText/fileEnc are just txt file paths).
std::ifstream in(filePlainText.c_str(),std::ios::binary);
std::ofstream out(fileEnc.c_str(),std::ios::binary);
Pipe pipe(get_cipher("AES-256/CBC",key,iv,ENCRYPTION),new DataSink_Stream(out));
pipe.start_msg();
in >> pipe;
pipe.end_msg();
out.flush();
out.close();
in.close();
DataSink_Stream accepts a ofsteam or ostream. So I figure I need to use an ostream when decrypting from file to variable. But how can I store the contents of the ostream into something I can feed into a QDomDocument?
Then for encrypting back into a file, use an istream into an ofstream, but how can I take feed the QDomDocument content into an istream?