2021-04-23 21:31:42 +02:00
|
|
|
#include <iostream>
|
|
|
|
#include <fstream>
|
2021-04-26 10:11:08 +02:00
|
|
|
#include <boost/program_options.hpp>
|
2021-04-26 21:29:58 +02:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
2021-04-26 10:11:08 +02:00
|
|
|
|
|
|
|
namespace po = boost::program_options;
|
|
|
|
|
|
|
|
void parseargs(int argc, char* argv[])
|
|
|
|
{
|
2021-04-26 21:29:58 +02:00
|
|
|
bool bInputHex = false;
|
|
|
|
bool bOutputHex = false;
|
|
|
|
std::string sInputFile;
|
|
|
|
std::string sOutputFile;
|
|
|
|
|
2021-04-26 10:11:08 +02:00
|
|
|
po::options_description desc("Allowed options");
|
|
|
|
desc.add_options()
|
|
|
|
("help", "Print this message")
|
2021-04-26 21:33:45 +02:00
|
|
|
("if", po::value<std::string>(), "Specify an input file")
|
2021-04-26 10:11:08 +02:00
|
|
|
("ih", "Input data is in hex")
|
2021-04-26 21:33:45 +02:00
|
|
|
("of", po::value<std::string>(), "Specify an output file")
|
2021-04-26 10:11:08 +02:00
|
|
|
("oh", "Output data in hex")
|
|
|
|
;
|
|
|
|
|
2021-04-26 21:33:45 +02:00
|
|
|
/*po::positional_options_description p;
|
|
|
|
p.add("input", -1);*/
|
2021-04-26 10:11:08 +02:00
|
|
|
|
|
|
|
po::variables_map vm;
|
|
|
|
po::store(po::parse_command_line(argc, argv, desc), vm);
|
|
|
|
po::notify(vm);
|
|
|
|
|
|
|
|
if (vm.count("help"))
|
|
|
|
{
|
|
|
|
std::cout << desc << std::endl;
|
|
|
|
}
|
|
|
|
|
2021-04-26 21:33:45 +02:00
|
|
|
if (vm.count("if"))
|
2021-04-26 10:11:08 +02:00
|
|
|
{
|
2021-04-26 21:33:45 +02:00
|
|
|
std::string file = vm["if"].as<std::string>();
|
2021-04-26 21:29:58 +02:00
|
|
|
std::string filecut = file.substr(1, file.length());
|
|
|
|
std::cout << filecut;
|
2021-04-26 10:11:08 +02:00
|
|
|
}
|
|
|
|
|
2021-04-26 21:29:58 +02:00
|
|
|
if (vm.count("ih"))
|
2021-04-26 10:11:08 +02:00
|
|
|
{
|
2021-04-26 21:29:58 +02:00
|
|
|
bool bInputHex = true;
|
2021-04-26 10:11:08 +02:00
|
|
|
}
|
|
|
|
|
2021-04-26 21:33:45 +02:00
|
|
|
if (vm.count("of"))
|
2021-04-26 10:11:08 +02:00
|
|
|
{
|
2021-04-26 21:33:45 +02:00
|
|
|
std::string file = vm["of"].as<std::string>();
|
2021-04-26 21:29:58 +02:00
|
|
|
std::string filecut = file.substr(1, file.length());
|
|
|
|
std::cout << filecut;
|
2021-04-26 10:11:08 +02:00
|
|
|
}
|
|
|
|
|
2021-04-26 21:29:58 +02:00
|
|
|
if (vm.count("oh"))
|
2021-04-26 10:11:08 +02:00
|
|
|
{
|
2021-04-26 21:29:58 +02:00
|
|
|
bool bOutputHex = true;
|
|
|
|
}
|
2021-04-26 10:11:08 +02:00
|
|
|
}
|
2021-04-23 21:31:42 +02:00
|
|
|
|
2021-04-26 21:29:58 +02:00
|
|
|
std::vector<char> xormessage(std::string sMessage, std::string sKey)
|
2021-04-23 21:31:42 +02:00
|
|
|
{
|
2021-04-26 21:29:58 +02:00
|
|
|
std::vector<char> cXORMessage;
|
|
|
|
int iKeyIndex = 0;
|
2021-04-26 10:11:08 +02:00
|
|
|
|
2021-04-26 21:29:58 +02:00
|
|
|
for (int iMessageIndex = 0; iMessageIndex < sMessage.length(); iMessageIndex++)
|
2021-04-23 21:31:42 +02:00
|
|
|
{
|
2021-04-26 21:29:58 +02:00
|
|
|
cXORMessage.push_back(sMessage[iMessageIndex] ^ sKey[iKeyIndex]);
|
|
|
|
iKeyIndex++;
|
|
|
|
if (iKeyIndex == sKey.length())
|
2021-04-23 21:31:42 +02:00
|
|
|
{
|
2021-04-26 21:29:58 +02:00
|
|
|
iKeyIndex = 0;
|
2021-04-23 21:31:42 +02:00
|
|
|
}
|
|
|
|
}
|
2021-04-26 21:29:58 +02:00
|
|
|
return cXORMessage;
|
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc, char* argv[])
|
|
|
|
{
|
|
|
|
//parseargs(argc, argv);
|
|
|
|
xormessage("hello ", "key");
|
|
|
|
|
|
|
|
|
2021-04-23 21:31:42 +02:00
|
|
|
}
|