// file XOR test 4 (needs newer boost than what ideone.com has)
#include <iostream>
#include <string>
#include <fstream>
#include <boost/filesystem.hpp>
#include <boost/iostreams/device/mapped_file.hpp>
void XOR( const std:: string & filePath, const std:: string & outputPath, const std:: string & key)
{
boost:: iostreams :: mapped_file_source in( filePath) ;
boost:: iostreams :: mapped_file_sink out( outputPath) ;
for ( std:: size_t pos = 0 ; pos < in.size ( ) ; ++ pos)
out.data ( ) [ pos] = in.data ( ) [ pos] ^ key[ pos % key.size ( ) ] ;
}
int main( )
{
XOR( "test.bin" , "test.out" , std:: string ( 32 , '*' ) ) ;
std:: cout << "File size: " << boost:: filesystem :: file_size ( "test.bin" ) << '\n ' ;
}
Ly8gZmlsZSBYT1IgdGVzdCA0IChuZWVkcyBuZXdlciBib29zdCB0aGFuIHdoYXQgaWRlb25lLmNvbSBoYXMpCiNpbmNsdWRlIDxpb3N0cmVhbT4KI2luY2x1ZGUgPHN0cmluZz4KI2luY2x1ZGUgPGZzdHJlYW0+CiNpbmNsdWRlIDxib29zdC9maWxlc3lzdGVtLmhwcD4KI2luY2x1ZGUgPGJvb3N0L2lvc3RyZWFtcy9kZXZpY2UvbWFwcGVkX2ZpbGUuaHBwPgp2b2lkIFhPUihjb25zdCBzdGQ6OnN0cmluZyYgZmlsZVBhdGgsIGNvbnN0IHN0ZDo6c3RyaW5nJiBvdXRwdXRQYXRoLCBjb25zdCBzdGQ6OnN0cmluZyYga2V5KQp7CiAgICBib29zdDo6aW9zdHJlYW1zOjptYXBwZWRfZmlsZV9zb3VyY2UgaW4oZmlsZVBhdGgpOwogICAgYm9vc3Q6Omlvc3RyZWFtczo6bWFwcGVkX2ZpbGVfc2luayBvdXQob3V0cHV0UGF0aCk7CgogICAgZm9yKHN0ZDo6c2l6ZV90IHBvcyA9IDA7IHBvcyA8IGluLnNpemUoKTsgKytwb3MpCiAgICAgICAgb3V0LmRhdGEoKVtwb3NdID0gaW4uZGF0YSgpW3Bvc10gXiBrZXlbcG9zICUga2V5LnNpemUoKV07Cn0KaW50IG1haW4oKQp7CiAgICBYT1IoInRlc3QuYmluIiwgInRlc3Qub3V0Iiwgc3RkOjpzdHJpbmcoMzIsICcqJykpOwogICAgc3RkOjpjb3V0IDw8ICJGaWxlIHNpemU6ICIgPDwgYm9vc3Q6OmZpbGVzeXN0ZW06OmZpbGVfc2l6ZSgidGVzdC5iaW4iKSA8PCAnXG4nOwp9Cg==
compilation info
/usr/include/boost/iostreams/device/mapped_file.hpp: In function ‘void XOR(const std::string&, const std::string&, const std::string&)’:
/usr/include/boost/iostreams/device/mapped_file.hpp:200: error: ‘char* boost::iostreams::mapped_file::data() const’ is inaccessible
prog.cpp:13: error: within this context
prog.cpp:13: error: ‘boost::iostreams::mapped_file’ is not an accessible base of ‘boost::iostreams::mapped_file_sink’
stdout