Add exceptoins

This commit is contained in:
Leonetienne 2022-05-26 22:06:04 +02:00
parent dddc2d16f6
commit fad87e9944
No known key found for this signature in database
GPG Key ID: C33879CD92E9708C
3 changed files with 34 additions and 17 deletions

View File

@ -10,6 +10,29 @@ void Configuration::Parse() {
return;
}
void Configuration::DecideModule() {
if (CommandlineInterface::Get().HasParam("--encrypt")) {
activeModule = MODULE::ENCRYPT;
return;
}
else if (CommandlineInterface::Get().HasParam("--decrypt")) {
activeModule = MODULE::DECRYPT;
return;
}
else if (CommandlineInterface::Get().HasParam("--hash")) {
activeModule = MODULE::HASH;
return;
}
else if (CommandlineInterface::Get().HasParam("--generate-keyfile")) {
activeModule = MODULE::GENERATE_KEYFILE;
return;
}
throw std::runtime_error("No module option found. Is the CLI parser configuration correct?.");
return;
}
void Configuration::DecideInputFrom() {
if (CommandlineInterface::Get().HasParam("--intext")) {
@ -46,23 +69,6 @@ void Configuration::DecideOutputTo() {
return;
}
void Configuration::DecideModule() {
if (CommandlineInterface::Get().HasParam("--encrypt")) {
activeModule = MODULE::ENCRYPT;
}
else if (CommandlineInterface::Get().HasParam("--decrypt")) {
activeModule == MODULE::DECRYPT;
}
else if (CommandlineInterface::Get().HasParam("--hash")) {
activeModule == MODULE::HASH;
}
else if (CommandlineInterface::Get().HasParam("--generate-keyfile")) {
activeModule == MODULE::GENERATE_KEYFILE;
}
return;
}
void Configuration::DecideIOBaseFormat() {
// Do we have any iobase specified?
@ -144,6 +150,11 @@ void Configuration::DecideIOBaseFormat() {
return;
}
// Fallback: Bytes
else {
iobaseFormat = IOBASE_FORMAT::BASE_BYTES;
}
return;
}

View File

@ -61,6 +61,9 @@ void ModulePrepareKey::PrepareKey() {
return;
}
throw std::runtime_error("No key option found. Is the CLI parser configuration correct?.");
return;
}

View File

@ -14,6 +14,9 @@ int main(int argc, char* const* argv) {
// Prepare the key
ModulePrepareKey::PrepareKey();
std::cout << ModulePrepareKey::GetKey().ToHexString() << std::endl;
return 0;
}