Move profiler command line to main, move key to external file, add register function
This commit is contained in:
38
main.cpp
38
main.cpp
@@ -1,12 +1,15 @@
|
||||
#include "aes.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
|
||||
#include "profiler.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
uint8_t key[16];
|
||||
|
||||
string prompt(char separator = '>')
|
||||
{
|
||||
PROFILER_RECORD;
|
||||
@@ -25,13 +28,12 @@ void print_help()
|
||||
{
|
||||
PROFILER_RECORD;
|
||||
// TODO Verify whether there are more/less commands
|
||||
cout << "The following commands are available: help, login, exit" << endl;
|
||||
cout << "The following commands are available: help, login, register, exit" << endl;
|
||||
}
|
||||
|
||||
void login()
|
||||
{
|
||||
PROFILER_RECORD;
|
||||
uint8_t key[16] = {0xA0,0x7C,0x3D,0x99,0xFA,0x00,0x02,0x46,0x97,0x33,0x73,0x50,0x31,0x7C,0xD3,0xDC}; // TODO Load me from a file
|
||||
cout << "Username";
|
||||
string username = prompt(':');
|
||||
cout << "Password";
|
||||
@@ -50,6 +52,12 @@ void login()
|
||||
// TODO Validate encrypted password
|
||||
}
|
||||
|
||||
void register_user()
|
||||
{
|
||||
PROFILER_RECORD;
|
||||
cout << "Registration is currently unavailable" << endl;
|
||||
}
|
||||
|
||||
bool execute_command(const string &input)
|
||||
{
|
||||
PROFILER_RECORD;
|
||||
@@ -62,19 +70,41 @@ bool execute_command(const string &input)
|
||||
{
|
||||
login();
|
||||
}
|
||||
else if (input == "register")
|
||||
{
|
||||
register_user();
|
||||
}
|
||||
else if (input == "help")
|
||||
{
|
||||
print_help();
|
||||
}
|
||||
else if (!profiler.command_line(input))
|
||||
else if (input == "profiler_print")
|
||||
{
|
||||
cout << "Invalid command '" << input << "'" << endl;
|
||||
profiler.print();
|
||||
}
|
||||
else if (input == "profiler_reset")
|
||||
{
|
||||
profiler.reset();
|
||||
}
|
||||
cout << "Invalid command '" << input << "'" << endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
void load_key()
|
||||
{
|
||||
PROFILER_RECORD;
|
||||
ifstream file("key.txt");
|
||||
string line;
|
||||
getline(file, line);
|
||||
for (int i = 0;i < 16;i++)
|
||||
{
|
||||
key[i] = stoi(line.substr(3 * i, 2), 0, 16);
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
PROFILER_RECORD;
|
||||
load_key();
|
||||
cout << "Welcome to the Secutech customer portal." << endl;
|
||||
cout << "How can we help you today? (type 'help' for help)" << endl;
|
||||
string input;
|
||||
|
||||
Reference in New Issue
Block a user