Able to view encrypted keys in the key management window
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
#include<iostream>
|
||||
#include"boost/filesystem.hpp"
|
||||
#include"FileNameRetrieval.h"
|
||||
#include"FolderStructure.h"
|
||||
|
||||
FileNameRetrieval::FileNameRetrieval() { }
|
||||
|
||||
std::vector<std::string> FileNameRetrieval::fileNameContainer() const { return fileNames; }
|
||||
void FileNameRetrieval::retrieveFileNames()
|
||||
{
|
||||
boost::filesystem::path directory(FolderStructure::keyDirectory);
|
||||
boost::filesystem::directory_iterator beg(directory), end;
|
||||
|
||||
for (; beg!=end; ++beg)
|
||||
if (beg->path().extension()==".txt")
|
||||
fileNames.push_back(beg->path().filename().string());
|
||||
for (auto fl: fileNames)
|
||||
std::cout<< fl<<std::endl;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
#ifndef FILENAMERETRIEVAL_H_
|
||||
#define FILENAMERETRIEVAL_H_
|
||||
|
||||
#include<vector>
|
||||
#include<string>
|
||||
|
||||
class FileNameRetrieval
|
||||
{
|
||||
public:
|
||||
FileNameRetrieval();
|
||||
|
||||
void retrieveFileNames();
|
||||
std::vector<std::string> fileNameContainer() const;
|
||||
private:
|
||||
std::vector<std::string> fileNames;
|
||||
};
|
||||
#endif
|
||||
+54
-8
@@ -1,15 +1,21 @@
|
||||
#include<QString>
|
||||
#include<QWidget>
|
||||
#include<QHeaderView>
|
||||
#include<QTableWidgetItem>
|
||||
#include<iostream>
|
||||
#include<string>
|
||||
#include<sstream>
|
||||
#include<cstdlib>
|
||||
#include<fstream>
|
||||
#include<ios>
|
||||
#include"boost/filesystem.hpp"
|
||||
#include"KeyManagementWindow.h"
|
||||
#include"Encryption.h"
|
||||
#include"GenerateKeys.h"
|
||||
#include"KeyRetrieval.h"
|
||||
#include"Conversions.h"
|
||||
#include"FileNameRetrieval.h"
|
||||
#include"FolderStructure.h"
|
||||
|
||||
KeyManagementWindow::KeyManagementWindow(QWidget* parent) : QDialog(parent)
|
||||
{
|
||||
@@ -20,22 +26,62 @@ KeyManagementWindow::KeyManagementWindow(QWidget* parent) : QDialog(parent)
|
||||
|
||||
void KeyManagementWindow::setContentsOfComboBox()
|
||||
{
|
||||
KeyRetrieval kr{};
|
||||
std::vector<int> c{kr.codeCharacterStructure()};
|
||||
selectionBox.get()->clear();
|
||||
FileNameRetrieval fnr;
|
||||
fnr.retrieveFileNames();
|
||||
std::vector<std::string> fn{fnr.fileNameContainer()};
|
||||
|
||||
for (auto index = 0u; index!=c.size(); ++index)
|
||||
for (auto fle: fn)
|
||||
{
|
||||
std::string ch{static_cast<char>(c[index])};
|
||||
QString bl = QString::fromStdString(ch);
|
||||
QString bl{QString::fromStdString(fle)};
|
||||
selectionBox.get()->addItem(bl);
|
||||
}
|
||||
}
|
||||
void KeyManagementWindow::setContentOfKeyView()
|
||||
{
|
||||
QString testQ;
|
||||
testQ.append(selectionBox.get()->currentText());
|
||||
std::string testS{FolderStructure::keyDirectory+testQ.toStdString()};
|
||||
|
||||
KeyRetrieval kr{testS};
|
||||
std::vector<int> asciiKeys{kr.codeCharacterStructure()};
|
||||
std::vector<std::string> asciiAssignment{kr.keyStructure()};
|
||||
|
||||
auto asciiKeysIter = asciiKeys.begin();
|
||||
auto asciiAssignmentIter = asciiAssignment.begin();
|
||||
for (auto row=0; row!=rowCount; ++row)
|
||||
{
|
||||
for (auto column=0; column!=columnCount; ++column)
|
||||
{
|
||||
if (column==0)
|
||||
{
|
||||
std::string val{*asciiKeysIter++};
|
||||
QString s{val.c_str()};
|
||||
elementView.get()->setItem(row, column, new QTableWidgetItem(s));
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string val{*asciiAssignmentIter++};
|
||||
QString s{val.c_str()};
|
||||
elementView.get()->setItem(row, column, new QTableWidgetItem(s));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
void KeyManagementWindow::setupWindow()
|
||||
{
|
||||
windowWidth = 450;
|
||||
windowHeight = 450;
|
||||
rowCount = 96;
|
||||
columnCount = 2;
|
||||
|
||||
elementView = unique_ptr<QTableView>{new QTableView};
|
||||
elementView = unique_ptr<QTableWidget>{new QTableWidget};
|
||||
|
||||
elementView.get()->setRowCount(rowCount);
|
||||
elementView.get()->setColumnCount(columnCount);
|
||||
tableHeader<<"character"<<"key";
|
||||
elementView.get()->setHorizontalHeaderLabels(tableHeader);
|
||||
elementView.get()->verticalHeader()->setVisible(false);
|
||||
|
||||
selectionBox = unique_ptr<QComboBox>{new QComboBox{}};
|
||||
|
||||
@@ -76,9 +122,9 @@ void KeyManagementWindow::setupWindow()
|
||||
}
|
||||
void KeyManagementWindow::connections()
|
||||
{
|
||||
QObject::connect(selectionBox.get(), SIGNAL(currentIndexChanged(int)), SLOT(test()));
|
||||
QObject::connect(generateNewKeys.get(), SIGNAL(clicked()), this, SLOT(generation()));
|
||||
QObject::connect(closeButton.get(), SIGNAL(clicked()), this, SLOT(exitApplication()));
|
||||
QObject::connect(actionButton.get(), SIGNAL(clicked()), this, SLOT(setContentOfKeyView()));
|
||||
}
|
||||
void KeyManagementWindow::test()
|
||||
{
|
||||
@@ -95,12 +141,12 @@ void KeyManagementWindow::test()
|
||||
|
||||
std::string value{encrypted[f]};
|
||||
QString v{QString::fromStdString(value)};
|
||||
//valueOfKey.get()->setText(v);
|
||||
}
|
||||
void KeyManagementWindow::generation()
|
||||
{
|
||||
GenerateKeys gk{};
|
||||
gk.keyMove();
|
||||
gk.keyDump();
|
||||
setContentsOfComboBox();
|
||||
}
|
||||
void KeyManagementWindow::exitApplication() { this->hide(); }
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define KEYMANAGEMENTWINDOW_H
|
||||
|
||||
#include<QDialog>
|
||||
#include<QString>
|
||||
#include<memory>
|
||||
#include"CommonWindow.h"
|
||||
#include"ViewingWindow.h"
|
||||
@@ -16,9 +17,11 @@ private slots:
|
||||
void test();
|
||||
void generation();
|
||||
void exitApplication();
|
||||
void setContentOfKeyView();
|
||||
private:
|
||||
void setContentsOfComboBox();
|
||||
void setupWindow();
|
||||
void connections();
|
||||
unique_ptr<QString> qSB;
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -8,6 +8,12 @@ KeyRetrieval::KeyRetrieval()
|
||||
retrieveKey();
|
||||
addToList();
|
||||
}
|
||||
KeyRetrieval::KeyRetrieval(const std::string fileName)
|
||||
{
|
||||
this->fileName.assign(fileName);
|
||||
retrieveKey();
|
||||
addToList();
|
||||
}
|
||||
|
||||
void KeyRetrieval::retrieveKey()
|
||||
{
|
||||
@@ -20,6 +26,7 @@ void KeyRetrieval::retrieveKey()
|
||||
if (keyChar[0]!='\0')
|
||||
keys.push_back(keyChar);
|
||||
}
|
||||
readKeys.close();
|
||||
}
|
||||
void KeyRetrieval::addToList()
|
||||
{
|
||||
@@ -39,6 +46,7 @@ void KeyRetrieval::addRange(int from, const int to)
|
||||
for (; from<=to; ++from)
|
||||
codeCharacter.push_back(from);
|
||||
}
|
||||
void KeyRetrieval::fileNameChoice(const std::string& fileName) { this->fileName.assign(fileName); }
|
||||
|
||||
std::vector<std::string> KeyRetrieval::keyStructure() { return keys; }
|
||||
std::vector<int> KeyRetrieval::codeCharacterStructure() { return codeCharacter; }
|
||||
|
||||
@@ -9,11 +9,13 @@ class KeyRetrieval
|
||||
{
|
||||
public:
|
||||
KeyRetrieval();
|
||||
KeyRetrieval(const std::string);
|
||||
~KeyRetrieval() = default;
|
||||
|
||||
void retrieveKey();
|
||||
void addToList();
|
||||
void addRange(int, const int);
|
||||
void fileNameChoice(const std::string&);
|
||||
|
||||
std::vector<std::string> keyStructure();
|
||||
std::vector<int> codeCharacterStructure();
|
||||
|
||||
@@ -73,11 +73,14 @@ void MainWindow::connections()
|
||||
|
||||
void MainWindow::changeCryptionType()
|
||||
{
|
||||
/**
|
||||
(cryptionChoice) ? cryptionSwitch->setText("decrypt chosen") : cryptionSwitch->setText("encrypt chosen");
|
||||
cryptionChoice = (cryptionChoice) ? false : true;
|
||||
*/
|
||||
}
|
||||
void MainWindow::determineCryption()
|
||||
{
|
||||
/**
|
||||
if (cryptionChoice)
|
||||
{
|
||||
Encryption ec{grabCryptionText()};
|
||||
@@ -98,6 +101,7 @@ void MainWindow::determineCryption()
|
||||
cryptionSwitch.get()->setText("encrypt chosen");
|
||||
cryptionChoice = true;
|
||||
}
|
||||
*/
|
||||
}
|
||||
void MainWindow::keyManagementWindow() { kh.get()->show(); }
|
||||
void MainWindow::passwordManageWindow() { ph.get()->show(); }
|
||||
|
||||
@@ -49,9 +49,6 @@ private:
|
||||
|
||||
unique_ptr<QTextEdit> textForCryption;
|
||||
|
||||
unique_ptr<QPushButton> cryptionButon;
|
||||
unique_ptr<QPushButton> cryptionSwitch;
|
||||
|
||||
unique_ptr<QMenu> fileMenu;
|
||||
unique_ptr<QMenu> editMenu;
|
||||
unique_ptr<QAction> closeApplication;
|
||||
|
||||
@@ -10,7 +10,7 @@ void PasswordManagementWindow::setupWindow()
|
||||
windowWidth=450;
|
||||
windowHeight=450;
|
||||
|
||||
elementView=unique_ptr<QTableView>{new QTableView};
|
||||
elementView=unique_ptr<QTableWidget>{new QTableWidget};
|
||||
|
||||
selectionBox=unique_ptr<QComboBox>{new QComboBox};
|
||||
actionButton=unique_ptr<QPushButton>{new QPushButton{"i3"}};
|
||||
|
||||
+5
-2
@@ -2,7 +2,8 @@
|
||||
#define VIEWINGWINDOW_H_
|
||||
|
||||
#include<QVBoxLayout>
|
||||
#include<QTableView>
|
||||
#include<QTableWidget>
|
||||
#include<QStringList>
|
||||
#include<QLineEdit>
|
||||
#include<QPushButton>
|
||||
#include<memory>
|
||||
@@ -18,8 +19,10 @@ protected:
|
||||
unique_ptr<QVBoxLayout> subLayoutGoonOne;
|
||||
unique_ptr<QVBoxLayout> subLayoutGoonTwo;
|
||||
unique_ptr<QLineEdit> crypticText;
|
||||
unique_ptr<QTableView> elementView;
|
||||
unique_ptr<QTableWidget> elementView;
|
||||
unique_ptr<QPushButton> closeButton;
|
||||
unique_ptr<QPushButton> generateNewKeys;
|
||||
QStringList tableHeader;
|
||||
int rowCount, columnCount;
|
||||
};
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user