fork download
  1. // file XOR test 2
  2. #include <iostream>
  3. #include <string>
  4. #include <fstream>
  5. #include <boost/filesystem.hpp>
  6. void XOR(const std::string& filePath, const std::string& outputPath, const std::string& key)
  7. {
  8. std::ifstream fin(filePath, std::ios::binary);
  9. std::istreambuf_iterator<char> beg(fin), end;
  10.  
  11. std::ofstream fout(outputPath, std::ios::binary);
  12. std::ostreambuf_iterator<char> out(fout);
  13.  
  14. std::string::const_iterator keyChr = key.begin();
  15.  
  16. while(beg != end)
  17. {
  18. *out++ = *beg++ ^ *keyChr;
  19.  
  20. if(++keyChr == key.end())
  21. keyChr = key.begin();
  22. }
  23. }
  24. int main()
  25. {
  26. XOR("test.bin", "test.out", std::string(32, '*'));
  27. std::cout << "File size: " << boost::filesystem::file_size("test.bin") << '\n';
  28. }
  29.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:5:32: fatal error: boost/filesystem.hpp: No such file or directory
compilation terminated.
stdout
Standard output is empty