From 4a3fd1c568a9b3cc5908505daf25f9f9efe73c7c Mon Sep 17 00:00:00 2001 From: x00010 Date: Mon, 26 Apr 2021 20:29:58 +0100 Subject: [PATCH] Added options and encryption function --- cxor.cpp | 68 +++++++++++++++++++++++++++++++++----------------------- 1 file changed, 40 insertions(+), 28 deletions(-) diff --git a/cxor.cpp b/cxor.cpp index 14c42d0..f5b49e4 100755 --- a/cxor.cpp +++ b/cxor.cpp @@ -1,15 +1,22 @@ #include #include #include +#include +#include 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(), "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 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 filecut = file.substr(1, file.length()); + std::cout << filecut; } - if (vm.count("")) + if (vm.count("oh")) { - - }*/ + bool bOutputHex = true; + } +} + +std::vector xormessage(std::string sMessage, std::string sKey) +{ + std::vector 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;*/ } \ No newline at end of file