Issue #1 #2 #4 are addressed in this commit. Added another window with controls for key management. Simple ASCII encryption

This commit is contained in:
amazing-username
2017-03-27 21:27:28 -05:00
parent 9894385576
commit 3f5d67e4cf
10 changed files with 194 additions and 16 deletions
+85
View File
@@ -0,0 +1,85 @@
#include "KeyManagementWindow.h"
#include "GenerateKeys.h"
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QString>
#include <string>
#include <iostream>
#include <cstdlib>
#include <fstream>
#include <ios>
KeyManagementWindow::KeyManagementWindow(QWidget* parent) : QDialog(parent)
{
GenerateKeys gk;
comboBoxOfKeys = new QComboBox;
valueOfKey = new QLineEdit;
QVBoxLayout* vBox = new QVBoxLayout;
QHBoxLayout* hBox = new QHBoxLayout;
setContentsOfComboBox();
hBox->addWidget(comboBoxOfKeys);
hBox->addWidget(valueOfKey);
vBox->addLayout(hBox);
setLayout(vBox);
setFixedWidth(400);
setFixedHeight(400);
setWindowTitle("Key Management Window");
QObject::connect(comboBoxOfKeys, SIGNAL(currentIndexChanged(int)), SLOT(test()));
}
void KeyManagementWindow::setContentsOfComboBox()
{
GenerateKeys gk;
for (unsigned short keyIndex = gk.startingCharacter; keyIndex <= gk.endingCharacter; keyIndex++)
{
std::string ch = "";
ch += gk.decryptedCharacters[keyIndex];
QString bl = QString::fromStdString(ch);
comboBoxOfKeys->addItem(bl);
}
}
void KeyManagementWindow::test()
{
GenerateKeys gk;
//std::cout << "bang bang!" << std::endl;
QString bo = comboBoxOfKeys->currentText();
std::string k = bo.toStdString();
char f;
std::fstream in;
in.open("strToCh.txt", std::ios::out);
in << k;
in.close();
in.open("strToCh.txt", std::ios::in);
in >> f;
in.close();
in.open("strToCh.txt", std::ios::out);
in << gk.encryptedCharacters[f];
in.close();
unsigned short yek;
in.open("strToCh.txt", std::ios::in);
in >> yek;
in.close();
std::string key = "";
key += std::to_string(yek);
//std::cout << gk.encryptedCharacters[f] << std::endl;
QString v = QString::fromStdString(key);
valueOfKey->setText(v);
}