Redirecting project's purpose into password encryption. Need to separate declaration from implementation
This commit is contained in:
+3
-3
@@ -18,8 +18,8 @@ protected:
|
|||||||
unique_ptr<QComboBox> selectionBox;
|
unique_ptr<QComboBox> selectionBox;
|
||||||
unique_ptr<QPushButton> actionButton;
|
unique_ptr<QPushButton> actionButton;
|
||||||
unique_ptr<QHBoxLayout> mainLayout;
|
unique_ptr<QHBoxLayout> mainLayout;
|
||||||
unique_ptr<VBoxLayout> subLayoutOne;
|
unique_ptr<QVBoxLayout> subLayoutOne;
|
||||||
unique_ptr<VBoxLayout> subLayoutTwo;
|
unique_ptr<QVBoxLayout> subLayoutTwo;
|
||||||
int height, width;
|
int windowHeight, windowWidth;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -8,8 +8,10 @@ class Conversions
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Conversions() = default;
|
Conversions() = default;
|
||||||
|
~Conversions()=default;
|
||||||
|
|
||||||
std::string cstringToString(char[], const int);
|
std::string cstringToString(char[], const int);
|
||||||
|
//char stringToChar(const string&);
|
||||||
private:
|
private:
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -22,4 +24,15 @@ std::string Conversions::cstringToString(char tmp[], const int size)
|
|||||||
cToS >> tmpString;
|
cToS >> tmpString;
|
||||||
return tmpString;
|
return tmpString;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
char Conversions::stringToChar(const string& tmp)
|
||||||
|
{
|
||||||
|
char tmpChar{};
|
||||||
|
stringstream sToC{};
|
||||||
|
for (auto index=0; index!=tmp.size(); ++index)
|
||||||
|
sToC << tmpChar;
|
||||||
|
sToC >> tmpChar;
|
||||||
|
return tmpChar;
|
||||||
|
}
|
||||||
|
*/
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+38
-22
@@ -1,4 +1,3 @@
|
|||||||
#include<QtWidgets>
|
|
||||||
#include<QString>
|
#include<QString>
|
||||||
#include<QWidget>
|
#include<QWidget>
|
||||||
#include<string>
|
#include<string>
|
||||||
@@ -10,37 +9,54 @@
|
|||||||
#include"Encryption.h"
|
#include"Encryption.h"
|
||||||
#include"GenerateKeys.h"
|
#include"GenerateKeys.h"
|
||||||
#include"KeyRetrieval.h"
|
#include"KeyRetrieval.h"
|
||||||
|
#include"Conversions.h"
|
||||||
|
|
||||||
KeyManagementWindow::KeyManagementWindow(QWidget* parent) : QDialog(parent)
|
KeyManagementWindow::KeyManagementWindow(QWidget* parent) : QDialog(parent)
|
||||||
{
|
{
|
||||||
comboBoxOfKeys = unique_ptr<QComboBox>{new QComboBox{}};
|
windowWidth = 450;
|
||||||
valueOfKey = unique_ptr<QLineEdit>{new QLineEdit{}};
|
windowHeight = 450;
|
||||||
generateNewDefaultKeys = unique_ptr<QPushButton>{new QPushButton(tr("Generate New Default Key"))};
|
|
||||||
closeButton = unique_ptr<QPushButton>{new QPushButton(tr("close"))};
|
elementView = unique_ptr<QTableView>{new QTableView};
|
||||||
|
|
||||||
|
selectionBox = unique_ptr<QComboBox>{new QComboBox{}};
|
||||||
|
|
||||||
|
generateNewKeys = unique_ptr<QPushButton>{new QPushButton(tr("Generate New Default Key"))};
|
||||||
|
closeButton = unique_ptr<QPushButton>{new QPushButton(tr("close"))};
|
||||||
|
actionButton = unique_ptr<QPushButton>{new QPushButton};
|
||||||
|
|
||||||
|
mainLayout = unique_ptr<QHBoxLayout>{new QHBoxLayout};
|
||||||
|
subLayoutOne = unique_ptr<QVBoxLayout>{new QVBoxLayout};
|
||||||
|
subLayoutTwo = unique_ptr<QVBoxLayout>{new QVBoxLayout};
|
||||||
|
|
||||||
|
subLayoutGoonOne = unique_ptr<QVBoxLayout>{new QVBoxLayout};
|
||||||
|
subLayoutGoonTwo = unique_ptr<QVBoxLayout>{new QVBoxLayout};
|
||||||
|
|
||||||
|
subLayoutOne.get()->addWidget(elementView.get());
|
||||||
|
|
||||||
|
subLayoutGoonOne.get()->addWidget(selectionBox.get());
|
||||||
|
subLayoutGoonOne.get()->addWidget(actionButton.get());
|
||||||
|
subLayoutGoonTwo.get()->addWidget(generateNewKeys.get());
|
||||||
|
subLayoutGoonTwo.get()->addWidget(closeButton.get());
|
||||||
|
|
||||||
|
subLayoutTwo.get()->addLayout(subLayoutGoonOne.get());
|
||||||
|
subLayoutTwo.get()->addLayout(subLayoutGoonTwo.get());
|
||||||
|
|
||||||
|
|
||||||
|
mainLayout.get()->addLayout(subLayoutOne.get());
|
||||||
|
mainLayout.get()->addLayout(subLayoutTwo.get());
|
||||||
|
|
||||||
vBox = unique_ptr<QVBoxLayout>{new QVBoxLayout};
|
|
||||||
hBox = unique_ptr<QHBoxLayout>{new QHBoxLayout};
|
|
||||||
hBox2 = unique_ptr<QHBoxLayout>{new QHBoxLayout};
|
|
||||||
|
|
||||||
setContentsOfComboBox();
|
setContentsOfComboBox();
|
||||||
hBox.get()->addWidget(comboBoxOfKeys.get());
|
|
||||||
hBox.get()->addWidget(valueOfKey.get());
|
|
||||||
|
|
||||||
hBox2.get()->addWidget(generateNewDefaultKeys.get());
|
setLayout(mainLayout.get());
|
||||||
hBox2.get()->addWidget(closeButton.get());
|
|
||||||
|
|
||||||
vBox.get()->addLayout(hBox.get());
|
|
||||||
vBox.get()->addLayout(hBox2.get());
|
|
||||||
|
|
||||||
setLayout(vBox.get());
|
|
||||||
|
|
||||||
setFixedWidth(windowWidth);
|
setFixedWidth(windowWidth);
|
||||||
setFixedHeight(windowHeight);
|
setFixedHeight(windowHeight);
|
||||||
|
|
||||||
setWindowTitle("Key Management Window");
|
setWindowTitle("Key Management Window");
|
||||||
|
|
||||||
QObject::connect(comboBoxOfKeys.get(), SIGNAL(currentIndexChanged(int)), SLOT(test()));
|
QObject::connect(selectionBox.get(), SIGNAL(currentIndexChanged(int)), SLOT(test()));
|
||||||
QObject::connect(generateNewDefaultKeys.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()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,7 +70,7 @@ void KeyManagementWindow::setContentsOfComboBox()
|
|||||||
{
|
{
|
||||||
std::string ch{static_cast<char>(c[index])};
|
std::string ch{static_cast<char>(c[index])};
|
||||||
QString bl = QString::fromStdString(ch);
|
QString bl = QString::fromStdString(ch);
|
||||||
comboBoxOfKeys.get()->addItem(bl);
|
selectionBox.get()->addItem(bl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void KeyManagementWindow::test()
|
void KeyManagementWindow::test()
|
||||||
@@ -62,7 +78,7 @@ void KeyManagementWindow::test()
|
|||||||
std::string emp{"d"};
|
std::string emp{"d"};
|
||||||
Encryption ec{emp};
|
Encryption ec{emp};
|
||||||
std::map<char, std::string> encrypted{ec.encryptedCharactersStructure()};
|
std::map<char, std::string> encrypted{ec.encryptedCharactersStructure()};
|
||||||
QString bo{comboBoxOfKeys.get()->currentText()};
|
QString bo{selectionBox.get()->currentText()};
|
||||||
std::string k{bo.toStdString()};
|
std::string k{bo.toStdString()};
|
||||||
char f{};
|
char f{};
|
||||||
|
|
||||||
@@ -72,7 +88,7 @@ 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);
|
//valueOfKey.get()->setText(v);
|
||||||
}
|
}
|
||||||
void KeyManagementWindow::generation()
|
void KeyManagementWindow::generation()
|
||||||
{
|
{
|
||||||
|
|||||||
+3
-18
@@ -8,16 +8,10 @@
|
|||||||
#include<QLineEdit>
|
#include<QLineEdit>
|
||||||
#include<QPushButton>
|
#include<QPushButton>
|
||||||
#include<memory>
|
#include<memory>
|
||||||
|
#include"CommonWindow.h"
|
||||||
|
#include"ViewingWindow.h"
|
||||||
|
|
||||||
class QHBoxLayout;
|
class KeyManagementWindow : public QDialog, public CommonWindow, public ViewingWindow
|
||||||
class QVBoxLayout;
|
|
||||||
class QComboBox;
|
|
||||||
class QLineEdit;
|
|
||||||
class QPushButton;
|
|
||||||
|
|
||||||
using std::unique_ptr;
|
|
||||||
|
|
||||||
class KeyManagementWindow : public QDialog
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
@@ -30,15 +24,6 @@ private slots:
|
|||||||
void generation();
|
void generation();
|
||||||
void exitApplication();
|
void exitApplication();
|
||||||
private:
|
private:
|
||||||
unique_ptr<QHBoxLayout> hBox;
|
|
||||||
unique_ptr<QHBoxLayout> hBox2;
|
|
||||||
unique_ptr<QVBoxLayout> vBox;
|
|
||||||
unique_ptr<QComboBox> comboBoxOfKeys;
|
|
||||||
unique_ptr<QLineEdit> valueOfKey;
|
|
||||||
unique_ptr<QPushButton> generateNewDefaultKeys;
|
|
||||||
unique_ptr<QPushButton> closeButton;
|
|
||||||
const int windowWidth{400};
|
|
||||||
const int windowHeight{400};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
#include<QApplication>
|
#include<QApplication>
|
||||||
|
|
||||||
#include"MessagingControls.h"
|
#include"MainWindow.h"
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
QApplication app(argc, argv);
|
QApplication app(argc, argv);
|
||||||
MessagingControls stuff{};
|
MainWindow stuff{};
|
||||||
|
|
||||||
stuff.show();
|
stuff.show();
|
||||||
|
|
||||||
|
|||||||
@@ -1,31 +1,30 @@
|
|||||||
#include<QString>
|
#include<QString>
|
||||||
#include<QIcon>
|
#include"MainWindow.h"
|
||||||
#include"MessagingControls.h"
|
|
||||||
#include"Encryption.h"
|
#include"Encryption.h"
|
||||||
#include"Decryption.h"
|
#include"Decryption.h"
|
||||||
#include"KeyRetrieval.h"
|
#include"KeyRetrieval.h"
|
||||||
|
|
||||||
MessagingControls::MessagingControls()
|
MainWindow::MainWindow()
|
||||||
{
|
{
|
||||||
mainWindowWidth = 450;
|
windowHeight = 450;
|
||||||
mainWindowHeight = 450;
|
windowWidth = 450;
|
||||||
setupMainWindow();
|
setupMainWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MessagingControls::setupMainWindow()
|
void MainWindow::setupMainWindow()
|
||||||
{
|
{
|
||||||
kh = unique_ptr<KeyManagementWindow>{new KeyManagementWindow};
|
kh = unique_ptr<KeyManagementWindow>{new KeyManagementWindow};
|
||||||
textForCryption = unique_ptr<QTextEdit>{new QTextEdit{}};
|
textForCryption = unique_ptr<QTextEdit>{new QTextEdit{}};
|
||||||
cryptionButon = unique_ptr<QPushButton>{new QPushButton(tr("XO"))};
|
actionButton = unique_ptr<QPushButton>{new QPushButton(tr("encrypt"))};
|
||||||
cryptionSwitch = unique_ptr<QPushButton>{new QPushButton(tr("encrypt chosen"))};
|
selectionBox = unique_ptr<QComboBox>{new QComboBox{}};
|
||||||
|
|
||||||
buttonLayout = unique_ptr<QVBoxLayout>{new QVBoxLayout};
|
buttonLayout = unique_ptr<QVBoxLayout>{new QVBoxLayout};
|
||||||
buttonWidget = unique_ptr<QWidget>{new QWidget};
|
buttonWidget = unique_ptr<QWidget>{new QWidget};
|
||||||
buttonDockWidget = unique_ptr<QDockWidget>{new QDockWidget};
|
buttonDockWidget = unique_ptr<QDockWidget>{new QDockWidget};
|
||||||
buttonDockWidget.get()->setWindowTitle(tr("Cryption Controls"));
|
buttonDockWidget.get()->setWindowTitle(tr("Cryption Controls"));
|
||||||
buttonLayout.get()->addWidget(cryptionButon.get());
|
buttonLayout.get()->addWidget(selectionBox.get());
|
||||||
buttonLayout.get()->addWidget(cryptionSwitch.get());
|
buttonLayout.get()->addWidget(actionButton.get());
|
||||||
buttonWidget.get()->setLayout(buttonLayout.get());
|
buttonWidget.get()->setLayout(buttonLayout.get());
|
||||||
buttonDockWidget.get()->setWidget(buttonWidget.get());
|
buttonDockWidget.get()->setWidget(buttonWidget.get());
|
||||||
buttonDockWidget.get()->setFeatures(QDockWidget::NoDockWidgetFeatures);
|
buttonDockWidget.get()->setFeatures(QDockWidget::NoDockWidgetFeatures);
|
||||||
@@ -36,20 +35,16 @@ void MessagingControls::setupMainWindow()
|
|||||||
cryptionArea.get()->setFeatures(QDockWidget::NoDockWidgetFeatures);
|
cryptionArea.get()->setFeatures(QDockWidget::NoDockWidgetFeatures);
|
||||||
addDockWidget(Qt::LeftDockWidgetArea, cryptionArea.get());
|
addDockWidget(Qt::LeftDockWidgetArea, cryptionArea.get());
|
||||||
|
|
||||||
addDockWidget(Qt::LeftDockWidgetArea, cryptionArea.get());
|
|
||||||
|
|
||||||
createMenus();
|
createMenus();
|
||||||
|
|
||||||
QObject::connect(closeApplication.get(), SIGNAL(triggered()), this, SLOT(exitApplication()));
|
QObject::connect(closeApplication.get(), SIGNAL(triggered()), this, SLOT(exitApplication()));
|
||||||
QObject::connect(cryptionSwitch.get(), SIGNAL(clicked()), this, SLOT(changeCryptionType()));
|
|
||||||
QObject::connect(cryptionButon.get(), SIGNAL(clicked()), this, SLOT(determineCryption()));
|
|
||||||
QObject::connect(keyEdit.get(), SIGNAL(triggered()), this, SLOT(keyManagementWindow()));
|
QObject::connect(keyEdit.get(), SIGNAL(triggered()), this, SLOT(keyManagementWindow()));
|
||||||
|
|
||||||
setWindowTitle("Encryption Decryption Messaging");
|
setWindowTitle("Encryption Decryption Messaging");
|
||||||
setFixedHeight(mainWindowHeight);
|
setFixedHeight(windowHeight);
|
||||||
setFixedWidth(mainWindowWidth);
|
setFixedWidth(windowWidth);
|
||||||
}
|
}
|
||||||
void MessagingControls::createMenus()
|
void MainWindow::createMenus()
|
||||||
{
|
{
|
||||||
fileMenu = unique_ptr<QMenu>{menuBar()->addMenu(tr("File"))};
|
fileMenu = unique_ptr<QMenu>{menuBar()->addMenu(tr("File"))};
|
||||||
editMenu = unique_ptr<QMenu>{menuBar()->addMenu(tr("Edit"))};
|
editMenu = unique_ptr<QMenu>{menuBar()->addMenu(tr("Edit"))};
|
||||||
@@ -65,12 +60,12 @@ void MessagingControls::createMenus()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MessagingControls::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 MessagingControls::determineCryption()
|
void MainWindow::determineCryption()
|
||||||
{
|
{
|
||||||
if (cryptionChoice)
|
if (cryptionChoice)
|
||||||
{
|
{
|
||||||
@@ -93,11 +88,11 @@ void MessagingControls::determineCryption()
|
|||||||
cryptionChoice = true;
|
cryptionChoice = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void MessagingControls::keyManagementWindow() { kh.get()->show(); }
|
void MainWindow::keyManagementWindow() { kh.get()->show(); }
|
||||||
void MessagingControls::exitApplication() { exit(0); }
|
void MainWindow::exitApplication() { exit(0); }
|
||||||
|
|
||||||
|
|
||||||
std::string MessagingControls::grabCryptionText()
|
std::string MainWindow::grabCryptionText()
|
||||||
{
|
{
|
||||||
auto placeHolder = textForCryption.get()->toPlainText();
|
auto placeHolder = textForCryption.get()->toPlainText();
|
||||||
|
|
||||||
@@ -1,9 +1,8 @@
|
|||||||
#ifndef MESSAGINGCONTROLS_H
|
#ifndef MAINWINDOW_H_
|
||||||
#define MESSAGINGCONTROLS_H
|
#define MAINWINDOW_H_
|
||||||
|
|
||||||
#include<QDialog>
|
#include<QDialog>
|
||||||
#include<QPushButton>
|
#include<QPushButton>
|
||||||
#include<QLineEdit>
|
|
||||||
#include<QTextEdit>
|
#include<QTextEdit>
|
||||||
#include<QLabel>
|
#include<QLabel>
|
||||||
#include<QMenuBar>
|
#include<QMenuBar>
|
||||||
@@ -15,16 +14,15 @@
|
|||||||
#include<QWidget>
|
#include<QWidget>
|
||||||
#include<memory>
|
#include<memory>
|
||||||
#include"KeyManagementWindow.h"
|
#include"KeyManagementWindow.h"
|
||||||
|
#include"CommonWindow.h"
|
||||||
|
|
||||||
|
|
||||||
using std::unique_ptr;
|
class MainWindow : public QMainWindow, public CommonWindow
|
||||||
|
|
||||||
class MessagingControls : public QMainWindow
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
MessagingControls();
|
MainWindow();
|
||||||
~MessagingControls() = default;
|
~MainWindow() = default;
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
@@ -44,10 +42,8 @@ private:
|
|||||||
unique_ptr<QDockWidget> cryptionArea;
|
unique_ptr<QDockWidget> cryptionArea;
|
||||||
|
|
||||||
unique_ptr<QLabel> lblOfEncryptedBox;
|
unique_ptr<QLabel> lblOfEncryptedBox;
|
||||||
unique_ptr<QLineEdit> encryptedBox;
|
|
||||||
|
|
||||||
unique_ptr<QTextEdit> textForCryption;
|
unique_ptr<QTextEdit> textForCryption;
|
||||||
unique_ptr<QTextEdit> textToDecrypt;
|
|
||||||
|
|
||||||
unique_ptr<QPushButton> cryptionButon;
|
unique_ptr<QPushButton> cryptionButon;
|
||||||
unique_ptr<QPushButton> cryptionSwitch;
|
unique_ptr<QPushButton> cryptionSwitch;
|
||||||
@@ -61,9 +57,6 @@ private:
|
|||||||
|
|
||||||
std::string grabCryptionText();
|
std::string grabCryptionText();
|
||||||
|
|
||||||
int mainWindowHeight;
|
|
||||||
int mainWindowWidth;
|
|
||||||
|
|
||||||
bool cryptionChoice;
|
bool cryptionChoice;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
#ifndef VIEWINGWINDOW_H_
|
#ifndef VIEWINGWINDOW_H_
|
||||||
#define VIEWINGWINDOW_H_
|
#define VIEWINGWINDOW_H_
|
||||||
|
|
||||||
|
#include<QVBoxLayout>
|
||||||
|
#include<QTableView>
|
||||||
#include<QLineEdit>
|
#include<QLineEdit>
|
||||||
#include<QPushButton>
|
#include<QPushButton>
|
||||||
#include<memory>
|
#include<memory>
|
||||||
@@ -13,6 +15,11 @@ public:
|
|||||||
ViewingWindow() = default;
|
ViewingWindow() = default;
|
||||||
~ViewingWindow() = default;
|
~ViewingWindow() = default;
|
||||||
protected:
|
protected:
|
||||||
|
unique_ptr<QVBoxLayout> subLayoutGoonOne;
|
||||||
|
unique_ptr<QVBoxLayout> subLayoutGoonTwo;
|
||||||
unique_ptr<QLineEdit> crypticText;
|
unique_ptr<QLineEdit> crypticText;
|
||||||
|
unique_ptr<QTableView> elementView;
|
||||||
|
unique_ptr<QPushButton> closeButton;
|
||||||
|
unique_ptr<QPushButton> generateNewKeys;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user