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<QString>
|
||||||
#include<QWidget>
|
#include<QWidget>
|
||||||
|
#include<QHeaderView>
|
||||||
|
#include<QTableWidgetItem>
|
||||||
|
#include<iostream>
|
||||||
#include<string>
|
#include<string>
|
||||||
#include<sstream>
|
#include<sstream>
|
||||||
#include<cstdlib>
|
#include<cstdlib>
|
||||||
#include<fstream>
|
#include<fstream>
|
||||||
#include<ios>
|
#include<ios>
|
||||||
|
#include"boost/filesystem.hpp"
|
||||||
#include"KeyManagementWindow.h"
|
#include"KeyManagementWindow.h"
|
||||||
#include"Encryption.h"
|
#include"Encryption.h"
|
||||||
#include"GenerateKeys.h"
|
#include"GenerateKeys.h"
|
||||||
#include"KeyRetrieval.h"
|
#include"KeyRetrieval.h"
|
||||||
#include"Conversions.h"
|
#include"Conversions.h"
|
||||||
|
#include"FileNameRetrieval.h"
|
||||||
|
#include"FolderStructure.h"
|
||||||
|
|
||||||
KeyManagementWindow::KeyManagementWindow(QWidget* parent) : QDialog(parent)
|
KeyManagementWindow::KeyManagementWindow(QWidget* parent) : QDialog(parent)
|
||||||
{
|
{
|
||||||
@@ -20,22 +26,62 @@ KeyManagementWindow::KeyManagementWindow(QWidget* parent) : QDialog(parent)
|
|||||||
|
|
||||||
void KeyManagementWindow::setContentsOfComboBox()
|
void KeyManagementWindow::setContentsOfComboBox()
|
||||||
{
|
{
|
||||||
KeyRetrieval kr{};
|
selectionBox.get()->clear();
|
||||||
std::vector<int> c{kr.codeCharacterStructure()};
|
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(fle)};
|
||||||
QString bl = QString::fromStdString(ch);
|
|
||||||
selectionBox.get()->addItem(bl);
|
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()
|
void KeyManagementWindow::setupWindow()
|
||||||
{
|
{
|
||||||
windowWidth = 450;
|
windowWidth = 450;
|
||||||
windowHeight = 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{}};
|
selectionBox = unique_ptr<QComboBox>{new QComboBox{}};
|
||||||
|
|
||||||
@@ -76,9 +122,9 @@ void KeyManagementWindow::setupWindow()
|
|||||||
}
|
}
|
||||||
void KeyManagementWindow::connections()
|
void KeyManagementWindow::connections()
|
||||||
{
|
{
|
||||||
QObject::connect(selectionBox.get(), SIGNAL(currentIndexChanged(int)), SLOT(test()));
|
|
||||||
QObject::connect(generateNewKeys.get(), SIGNAL(clicked()), this, SLOT(generation()));
|
QObject::connect(generateNewKeys.get(), SIGNAL(clicked()), this, SLOT(generation()));
|
||||||
QObject::connect(closeButton.get(), SIGNAL(clicked()), this, SLOT(exitApplication()));
|
QObject::connect(closeButton.get(), SIGNAL(clicked()), this, SLOT(exitApplication()));
|
||||||
|
QObject::connect(actionButton.get(), SIGNAL(clicked()), this, SLOT(setContentOfKeyView()));
|
||||||
}
|
}
|
||||||
void KeyManagementWindow::test()
|
void KeyManagementWindow::test()
|
||||||
{
|
{
|
||||||
@@ -95,12 +141,12 @@ void KeyManagementWindow::test()
|
|||||||
|
|
||||||
std::string value{encrypted[f]};
|
std::string value{encrypted[f]};
|
||||||
QString v{QString::fromStdString(value)};
|
QString v{QString::fromStdString(value)};
|
||||||
//valueOfKey.get()->setText(v);
|
|
||||||
}
|
}
|
||||||
void KeyManagementWindow::generation()
|
void KeyManagementWindow::generation()
|
||||||
{
|
{
|
||||||
GenerateKeys gk{};
|
GenerateKeys gk{};
|
||||||
gk.keyMove();
|
gk.keyMove();
|
||||||
gk.keyDump();
|
gk.keyDump();
|
||||||
|
setContentsOfComboBox();
|
||||||
}
|
}
|
||||||
void KeyManagementWindow::exitApplication() { this->hide(); }
|
void KeyManagementWindow::exitApplication() { this->hide(); }
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
#define KEYMANAGEMENTWINDOW_H
|
#define KEYMANAGEMENTWINDOW_H
|
||||||
|
|
||||||
#include<QDialog>
|
#include<QDialog>
|
||||||
|
#include<QString>
|
||||||
#include<memory>
|
#include<memory>
|
||||||
#include"CommonWindow.h"
|
#include"CommonWindow.h"
|
||||||
#include"ViewingWindow.h"
|
#include"ViewingWindow.h"
|
||||||
@@ -16,9 +17,11 @@ private slots:
|
|||||||
void test();
|
void test();
|
||||||
void generation();
|
void generation();
|
||||||
void exitApplication();
|
void exitApplication();
|
||||||
|
void setContentOfKeyView();
|
||||||
private:
|
private:
|
||||||
void setContentsOfComboBox();
|
void setContentsOfComboBox();
|
||||||
void setupWindow();
|
void setupWindow();
|
||||||
void connections();
|
void connections();
|
||||||
|
unique_ptr<QString> qSB;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -8,6 +8,12 @@ KeyRetrieval::KeyRetrieval()
|
|||||||
retrieveKey();
|
retrieveKey();
|
||||||
addToList();
|
addToList();
|
||||||
}
|
}
|
||||||
|
KeyRetrieval::KeyRetrieval(const std::string fileName)
|
||||||
|
{
|
||||||
|
this->fileName.assign(fileName);
|
||||||
|
retrieveKey();
|
||||||
|
addToList();
|
||||||
|
}
|
||||||
|
|
||||||
void KeyRetrieval::retrieveKey()
|
void KeyRetrieval::retrieveKey()
|
||||||
{
|
{
|
||||||
@@ -20,6 +26,7 @@ void KeyRetrieval::retrieveKey()
|
|||||||
if (keyChar[0]!='\0')
|
if (keyChar[0]!='\0')
|
||||||
keys.push_back(keyChar);
|
keys.push_back(keyChar);
|
||||||
}
|
}
|
||||||
|
readKeys.close();
|
||||||
}
|
}
|
||||||
void KeyRetrieval::addToList()
|
void KeyRetrieval::addToList()
|
||||||
{
|
{
|
||||||
@@ -39,6 +46,7 @@ void KeyRetrieval::addRange(int from, const int to)
|
|||||||
for (; from<=to; ++from)
|
for (; from<=to; ++from)
|
||||||
codeCharacter.push_back(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<std::string> KeyRetrieval::keyStructure() { return keys; }
|
||||||
std::vector<int> KeyRetrieval::codeCharacterStructure() { return codeCharacter; }
|
std::vector<int> KeyRetrieval::codeCharacterStructure() { return codeCharacter; }
|
||||||
|
|||||||
@@ -9,11 +9,13 @@ class KeyRetrieval
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
KeyRetrieval();
|
KeyRetrieval();
|
||||||
|
KeyRetrieval(const std::string);
|
||||||
~KeyRetrieval() = default;
|
~KeyRetrieval() = default;
|
||||||
|
|
||||||
void retrieveKey();
|
void retrieveKey();
|
||||||
void addToList();
|
void addToList();
|
||||||
void addRange(int, const int);
|
void addRange(int, const int);
|
||||||
|
void fileNameChoice(const std::string&);
|
||||||
|
|
||||||
std::vector<std::string> keyStructure();
|
std::vector<std::string> keyStructure();
|
||||||
std::vector<int> codeCharacterStructure();
|
std::vector<int> codeCharacterStructure();
|
||||||
|
|||||||
@@ -73,11 +73,14 @@ void MainWindow::connections()
|
|||||||
|
|
||||||
void MainWindow::changeCryptionType()
|
void MainWindow::changeCryptionType()
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
(cryptionChoice) ? cryptionSwitch->setText("decrypt chosen") : cryptionSwitch->setText("encrypt chosen");
|
(cryptionChoice) ? cryptionSwitch->setText("decrypt chosen") : cryptionSwitch->setText("encrypt chosen");
|
||||||
cryptionChoice = (cryptionChoice) ? false : true;
|
cryptionChoice = (cryptionChoice) ? false : true;
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
void MainWindow::determineCryption()
|
void MainWindow::determineCryption()
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
if (cryptionChoice)
|
if (cryptionChoice)
|
||||||
{
|
{
|
||||||
Encryption ec{grabCryptionText()};
|
Encryption ec{grabCryptionText()};
|
||||||
@@ -98,6 +101,7 @@ void MainWindow::determineCryption()
|
|||||||
cryptionSwitch.get()->setText("encrypt chosen");
|
cryptionSwitch.get()->setText("encrypt chosen");
|
||||||
cryptionChoice = true;
|
cryptionChoice = true;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
void MainWindow::keyManagementWindow() { kh.get()->show(); }
|
void MainWindow::keyManagementWindow() { kh.get()->show(); }
|
||||||
void MainWindow::passwordManageWindow() { ph.get()->show(); }
|
void MainWindow::passwordManageWindow() { ph.get()->show(); }
|
||||||
|
|||||||
@@ -49,9 +49,6 @@ private:
|
|||||||
|
|
||||||
unique_ptr<QTextEdit> textForCryption;
|
unique_ptr<QTextEdit> textForCryption;
|
||||||
|
|
||||||
unique_ptr<QPushButton> cryptionButon;
|
|
||||||
unique_ptr<QPushButton> cryptionSwitch;
|
|
||||||
|
|
||||||
unique_ptr<QMenu> fileMenu;
|
unique_ptr<QMenu> fileMenu;
|
||||||
unique_ptr<QMenu> editMenu;
|
unique_ptr<QMenu> editMenu;
|
||||||
unique_ptr<QAction> closeApplication;
|
unique_ptr<QAction> closeApplication;
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ void PasswordManagementWindow::setupWindow()
|
|||||||
windowWidth=450;
|
windowWidth=450;
|
||||||
windowHeight=450;
|
windowHeight=450;
|
||||||
|
|
||||||
elementView=unique_ptr<QTableView>{new QTableView};
|
elementView=unique_ptr<QTableWidget>{new QTableWidget};
|
||||||
|
|
||||||
selectionBox=unique_ptr<QComboBox>{new QComboBox};
|
selectionBox=unique_ptr<QComboBox>{new QComboBox};
|
||||||
actionButton=unique_ptr<QPushButton>{new QPushButton{"i3"}};
|
actionButton=unique_ptr<QPushButton>{new QPushButton{"i3"}};
|
||||||
|
|||||||
+5
-2
@@ -2,7 +2,8 @@
|
|||||||
#define VIEWINGWINDOW_H_
|
#define VIEWINGWINDOW_H_
|
||||||
|
|
||||||
#include<QVBoxLayout>
|
#include<QVBoxLayout>
|
||||||
#include<QTableView>
|
#include<QTableWidget>
|
||||||
|
#include<QStringList>
|
||||||
#include<QLineEdit>
|
#include<QLineEdit>
|
||||||
#include<QPushButton>
|
#include<QPushButton>
|
||||||
#include<memory>
|
#include<memory>
|
||||||
@@ -18,8 +19,10 @@ protected:
|
|||||||
unique_ptr<QVBoxLayout> subLayoutGoonOne;
|
unique_ptr<QVBoxLayout> subLayoutGoonOne;
|
||||||
unique_ptr<QVBoxLayout> subLayoutGoonTwo;
|
unique_ptr<QVBoxLayout> subLayoutGoonTwo;
|
||||||
unique_ptr<QLineEdit> crypticText;
|
unique_ptr<QLineEdit> crypticText;
|
||||||
unique_ptr<QTableView> elementView;
|
unique_ptr<QTableWidget> elementView;
|
||||||
unique_ptr<QPushButton> closeButton;
|
unique_ptr<QPushButton> closeButton;
|
||||||
unique_ptr<QPushButton> generateNewKeys;
|
unique_ptr<QPushButton> generateNewKeys;
|
||||||
|
QStringList tableHeader;
|
||||||
|
int rowCount, columnCount;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user