From 3570ecefe27036958d42c382629278056c963c28 Mon Sep 17 00:00:00 2001 From: lucaspalomodevelop Date: Thu, 19 Oct 2023 18:24:34 +0200 Subject: [PATCH] add cryptopp lib --- libs/cryptopp | 1 + src/main.cpp | 23 ++++++++++++++++++++++- src/main.h | 9 +++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) create mode 160000 libs/cryptopp diff --git a/libs/cryptopp b/libs/cryptopp new file mode 160000 index 0000000..af7d105 --- /dev/null +++ b/libs/cryptopp @@ -0,0 +1 @@ +Subproject commit af7d1050bf2287072edd629be133da458a3cf978 diff --git a/src/main.cpp b/src/main.cpp index 9124960..726ce88 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -111,12 +111,18 @@ void runScript(int argc, char *argv[]) } // encrypt a script in the autom directory +std::string encrypt(std::string content, std::string pass) +{ + +} + void encryptScript(int argc, char *argv[]) { std::string password = ""; std::string password2 = ""; std::string script = home_dir + "/" + argv[1]; - + std::string scriptContent = ""; + std::string encryptScriptContent = "CRYPT;AES256\n"; std::cout << "encrypting file " << script << std::endl; std::cout << "Enter password: "; password = EnterPassword(); @@ -140,9 +146,24 @@ void encryptScript(int argc, char *argv[]) std::cout << "Script " << argv[1] << " does not exist" << std::endl; return; } + + std::fstream file(script); + std::string line; + while (getline(file, line)) + { + scriptContent += line + "\n"; + } + file.close(); + + encryptScriptContent += encrypt(scriptContent, password); } // encrypt a script in the autom directory + +std::string decrypt(std::string content, std::string pass) +{ +} + void decryptScript(int argc, char *argv[]) { std::cout << "decrypting file " << argv[1] << std::endl; diff --git a/src/main.h b/src/main.h index d2f561f..cb50ef1 100644 --- a/src/main.h +++ b/src/main.h @@ -10,6 +10,13 @@ #include #include +#include "../libs/cryptopp/cryptlib.h" +#include "../libs/cryptopp/rijndael.h" +#include "../libs/cryptopp/modes.h" +#include "../libs/cryptopp/files.h" +#include "../libs/cryptopp/osrng.h" +#include "../libs/cryptopp/hex.h" + #include "inputparser.h" #include "command.h" #include "settings.h" @@ -35,8 +42,10 @@ void removeScript(int argc, char *argv[]); // show a script in the autom directory void showScript(int argc, char *argv[]); // encrypt a script in the autom directory +std::string encrypt(std::string content, std::string pass); void encryptScript(int argc, char *argv[]); // decrypt a script in the autom directory +std::string decrypt(std::string content, std::string pass); void decryptScript(int argc, char *argv[]); std::string EnterPassword();