diff --git a/GCryptCLI/include/ModuleGenerateKeyfile.h b/GCryptCLI/include/ModuleGenerateKeyfile.h new file mode 100644 index 0000000..eaf5cef --- /dev/null +++ b/GCryptCLI/include/ModuleGenerateKeyfile.h @@ -0,0 +1,14 @@ +#ifndef GCRYPTCLI_MODULE_GENERATEKEYFILE_H +#define GCRYPTCLI_MODULE_GENERATEKEYFILE_H + +namespace Module { + // This class has the task to prepare and supply the encryption key. + class GenerateKeyfile { + public: + //! Will write the key to a file + static void Run(); + }; +} + +#endif + diff --git a/GCryptCLI/src/ModuleGenerateKeyfile.cpp b/GCryptCLI/src/ModuleGenerateKeyfile.cpp new file mode 100644 index 0000000..2b4cd6d --- /dev/null +++ b/GCryptCLI/src/ModuleGenerateKeyfile.cpp @@ -0,0 +1,17 @@ +#include "ModuleGenerateKeyfile.h" + +#include "KeyManager.h" +#include "CommandlineInterface.h" + +using namespace Leonetienne::GCrypt; +using namespace Module; + +void GenerateKeyfile::Run() { + + KeyManager::GetKey().WriteToFile( + CommandlineInterface::Get()["--generate-keyfile"].GetString() + ); + + return; +} + diff --git a/GCryptCLI/src/main.cpp b/GCryptCLI/src/main.cpp index af8f449..2d851b4 100644 --- a/GCryptCLI/src/main.cpp +++ b/GCryptCLI/src/main.cpp @@ -1,6 +1,7 @@ #include "CommandlineInterface.h" #include "Configuration.h" #include "KeyManager.h" +#include "ModuleGenerateKeyfile.h" int main(int argc, char* const* argv) { @@ -13,6 +14,12 @@ int main(int argc, char* const* argv) { // Prepare the key KeyManager::PrepareKey(); + // Launch our module + switch (Configuration::activeModule) { + case Configuration::MODULE::GENERATE_KEYFILE: + Module::GenerateKeyfile::Run(); + } + return 0; }