// file XOR test 1
#include <string>
#include <iostream>
#include <fstream>
#include <boost/filesystem.hpp>
bool XOR(const std::string& filePath, const std::string& outputPath, const std::string& key)
{
    std::ifstream in(filePath.c_str(), std::ios::binary);
    std::ofstream out(outputPath.c_str(), std::ios::binary);

    //files succesfully opened?
    if(!in || !out)
        return false;

    std::string::const_iterator keyChr = key.begin();

    //start encryption
    char chr;
    while(in.get(chr) && out)
    {
        out << char(chr ^ (*keyChr));

        if(++keyChr == key.end())
            keyChr = key.begin();
    }

    in.close();
    out.close();

    return true;
}
int main()
{
    XOR("test.bin", "test.out", std::string(32, '*'));
    std::cout << "File size: " << boost::filesystem::file_size("test.bin") << '\n';
}
