Implement GenerateKeyfile module

This commit is contained in:
Leonetienne 2022-05-27 17:04:16 +02:00
parent 191b17c631
commit 93be4d9cdc
No known key found for this signature in database
GPG Key ID: C33879CD92E9708C
3 changed files with 38 additions and 0 deletions

View File

@ -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

View File

@ -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;
}

View File

@ -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;
}