fork(1) download
  1. // file XOR test 1
  2. #include <string>
  3. #include <iostream>
  4. #include <fstream>
  5. #include <boost/filesystem.hpp>
  6. bool XOR(const std::string& filePath, const std::string& outputPath, const std::string& key)
  7. {
  8. std::ifstream in(filePath.c_str(), std::ios::binary);
  9. std::ofstream out(outputPath.c_str(), std::ios::binary);
  10.  
  11. //files succesfully opened?
  12. if(!in || !out)
  13. return false;
  14.  
  15. std::string::const_iterator keyChr = key.begin();
  16.  
  17. //start encryption
  18. char chr;
  19. while(in.get(chr) && out)
  20. {
  21. out << char(chr ^ (*keyChr));
  22.  
  23. if(++keyChr == key.end())
  24. keyChr = key.begin();
  25. }
  26.  
  27. in.close();
  28. out.close();
  29.  
  30. return true;
  31. }
  32. int main()
  33. {
  34. XOR("test.bin", "test.out", std::string(32, '*'));
  35. std::cout << "File size: " << boost::filesystem::file_size("test.bin") << '\n';
  36. }
  37.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
/home/VU1qjY/ccB9mvds.o: In function `global constructors keyed to _Z3XORRKSsS0_S0_':
prog.cpp:(.text+0x2c): undefined reference to `boost::system::get_system_category()'
prog.cpp:(.text+0x36): undefined reference to `boost::system::get_generic_category()'
prog.cpp:(.text+0x40): undefined reference to `boost::system::get_generic_category()'
prog.cpp:(.text+0x4a): undefined reference to `boost::system::get_generic_category()'
prog.cpp:(.text+0x54): undefined reference to `boost::system::get_system_category()'
/home/VU1qjY/ccB9mvds.o: In function `boost::enable_if<boost::filesystem::is_basic_path<boost::filesystem::basic_path<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, boost::filesystem::path_traits> >, unsigned long long>::type boost::filesystem::file_size<boost::filesystem::basic_path<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, boost::filesystem::path_traits> >(boost::filesystem::basic_path<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, boost::filesystem::path_traits> const&)':
prog.cpp:(.text._ZN5boost10filesystem9file_sizeINS0_10basic_pathISsNS0_11path_traitsEEEEENS_9enable_ifINS0_13is_basic_pathIT_EEyE4typeERKS7_[boost::enable_if<boost::filesystem::is_basic_path<boost::filesystem::basic_path<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, boost::filesystem::path_traits> >, unsigned long long>::type boost::filesystem::file_size<boost::filesystem::basic_path<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, boost::filesystem::path_traits> >(boost::filesystem::basic_path<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, boost::filesystem::path_traits> const&)]+0x53): undefined reference to `boost::filesystem::detail::file_size_api(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
collect2: ld returned 1 exit status
stdout
Standard output is empty