1
我在Qt中使用Botan庫進行加密。我有它的工作,我可以加密和解密從一個文件到另一個,但我試圖改變它從文件加密到QDomDocument(加密文件將只是一個XML文件),並從QDomDocument解密回來到一個文件。輸出Botan加密結果到QDomDocument,反之亦然
這是我到目前爲止的實際加密(filePlainText/fileEnc只是txt文件路徑)。
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接受一個ofsteam或ostream。所以我想我需要使用ostream從文件解密到變量。但是,如何將ostream的內容存儲到我可以輸入到QDomDocument中的內容?
然後,爲了將文件加密回一個文件,使用istream到一個文件流中,但我怎樣才能將QDomDocument內容提交到一個istream?
完美!這就是我所缺少的 - 從QByteArray轉換到QDom /流。謝謝! – giraffee 2012-03-12 00:37:30