Added options and encryption function

This commit is contained in:
x00010 2021-04-26 20:29:58 +01:00
parent 30ff0b0283
commit 4a3fd1c568
1 changed files with 40 additions and 28 deletions

View File

@ -1,15 +1,22 @@
#include <iostream>
#include <fstream>
#include <boost/program_options.hpp>
#include <string>
#include <vector>
namespace po = boost::program_options;
void parseargs(int argc, char* argv[])
{
bool bInputHex = false;
bool bOutputHex = false;
std::string sInputFile;
std::string sOutputFile;
po::options_description desc("Allowed options");
desc.add_options()
("help", "Print this message")
("input,i", "Specify an input file")
("input,i", po::value<std::string>(), "Specify an input file")
("ih", "Input data is in hex")
("output,o", "Specify an output file")
("oh", "Output data in hex")
@ -29,45 +36,50 @@ void parseargs(int argc, char* argv[])
if (vm.count("input"))
{
std::cout << "input works";
std::string file = vm["input"].as<std::string>();
std::string filecut = file.substr(1, file.length());
std::cout << filecut;
}
/*if (vm.count(""))
if (vm.count("ih"))
{
bool bInputHex = true;
}
if (vm.count(""))
if (vm.count("output"))
{
std::string file = vm["output"].as<std::string>();
std::string filecut = file.substr(1, file.length());
std::cout << filecut;
}
if (vm.count(""))
if (vm.count("oh"))
{
bool bOutputHex = true;
}
}
}*/
std::vector<char> xormessage(std::string sMessage, std::string sKey)
{
std::vector<char> cXORMessage;
int iKeyIndex = 0;
for (int iMessageIndex = 0; iMessageIndex < sMessage.length(); iMessageIndex++)
{
cXORMessage.push_back(sMessage[iMessageIndex] ^ sKey[iKeyIndex]);
iKeyIndex++;
if (iKeyIndex == sKey.length())
{
iKeyIndex = 0;
}
}
return cXORMessage;
}
int main(int argc, char* argv[])
{
parseargs(argc, argv);
//parseargs(argc, argv);
xormessage("hello ", "key");
/*std::fstream fInput;
fInput.open(argv[1], std::ios::in);
if (!fInput)
{
std::cout << "File does not exist.";
}
else
{
char ch;
while (!fInput.eof())
{
fInput >> ch;
std::cout << ch;
}
std::cout << std::endl;
fInput.close();
}
return 0;*/
}