This repository has been archived on 2026-07-02. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
PasswordEncryption/KeyManagementWindow.cpp
T
2017-04-28 16:01:22 -05:00

87 lines
1.8 KiB
C++

#include"KeyManagementWindow.h"
#include"GenerateKeys.h"
#include<QtWidgets>
#include<QString>
#include<QWidget>
#include<string>
#include<sstream>
#include<iostream>
#include<cstdlib>
#include<fstream>
#include<ios>
KeyManagementWindow::KeyManagementWindow(QWidget* parent) : QDialog(parent)
{
GenerateKeys gk{};
comboBoxOfKeys = new QComboBox{};
valueOfKey = new QLineEdit{};
generateNewDefaultKeys = new QPushButton(tr("Generate New Default Key"));
vBox = new QVBoxLayout;
hBox = new QHBoxLayout;
QHBoxLayout* hBox2 = new QHBoxLayout;
setContentsOfComboBox();
hBox->addWidget(comboBoxOfKeys);
hBox->addWidget(valueOfKey);
hBox2->addWidget(generateNewDefaultKeys);
vBox->addLayout(hBox);
vBox->addLayout(hBox2);
setLayout(vBox);
setFixedWidth(400);
setFixedHeight(400);
setWindowTitle("Key Management Window");
QObject::connect(comboBoxOfKeys, SIGNAL(currentIndexChanged(int)), SLOT(test()));
QObject::connect(generateNewDefaultKeys, SIGNAL(clicked()), this, SLOT(generation()));
}
KeyManagementWindow::~KeyManagementWindow()
{
delete comboBoxOfKeys;
delete valueOfKey;
delete generateNewDefaultKeys;
delete hBox;
delete vBox;
}
void KeyManagementWindow::setContentsOfComboBox()
{
GenerateKeys gk;
for (auto index = 0u; index!=gk.allCharacters.size(); ++index)
{
std::string ch{static_cast<char>(gk.allCharacters[index])};
QString bl = QString::fromStdString(ch);
comboBoxOfKeys->addItem(bl);
}
}
void KeyManagementWindow::test()
{
GenerateKeys gk{};
QString bo{comboBoxOfKeys->currentText()};
std::string k{bo.toStdString()};
char f{};
std::stringstream lazy{};
lazy << k;
lazy >> f;
std::string value{gk.encryptedCharacters[f]};
QString v{QString::fromStdString(value)};
valueOfKey->setText(v);
}
void KeyManagementWindow::generation()
{
GenerateKeys gk{};
gk.keyMove();
gk.keyDump();
}