Addressed Issue #10
This commit is contained in:
@@ -8,7 +8,6 @@
|
||||
Decryption::Decryption(const string& message)
|
||||
{
|
||||
this->message = message;
|
||||
//setupMap();
|
||||
decryptMessage();
|
||||
}
|
||||
Decryption::Decryption(const Password<>& py, const Key<>& ky)
|
||||
@@ -34,7 +33,6 @@ void Decryption::decryptMessage()
|
||||
string messageToBeDecrypted{}, decryptedMessage{};
|
||||
|
||||
while(ioEvent >> messageToBeDecrypted);
|
||||
//std::cout << messageToBeDecrypted << std::endl;
|
||||
|
||||
ioEvent.close();
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@ Encryption::Encryption(const string& message, const string& keyPath)
|
||||
this->message = message;
|
||||
setupMap(keyPath);
|
||||
configurePasswordFileName();
|
||||
//encryptMessage();
|
||||
}
|
||||
Encryption::Encryption(const Password<>& pass, const Key<>& ky)
|
||||
{
|
||||
|
||||
@@ -7,17 +7,6 @@ GeneratePasswordFileName::GeneratePasswordFileName()
|
||||
{
|
||||
generatedFileName();
|
||||
}
|
||||
/*
|
||||
void GeneratePasswordFileName::setupTime()
|
||||
{
|
||||
time_t epochTime = time(0);
|
||||
tm* currentTime = localtime(&epochTime);
|
||||
|
||||
year = 1900 + currentTime->tm_year;
|
||||
month = 1 + currentTime->tm_mon;
|
||||
dayOfMonth = currentTime->tm_mday;
|
||||
}
|
||||
*/
|
||||
void GeneratePasswordFileName::generatedFileName()
|
||||
{
|
||||
filename.assign(dateString());
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include"ViewingWindow.h"
|
||||
|
||||
class MainWindow;
|
||||
class PasswordManagementWindow;
|
||||
|
||||
class KeyManagementWindow : public QDialog, public CommonWindow, public ViewingWindow
|
||||
{
|
||||
|
||||
+21
-35
@@ -8,6 +8,7 @@
|
||||
#include"FolderStructure.h"
|
||||
#include"Key.h"
|
||||
#include"Password.h"
|
||||
#include"SaveFile.h" //Do not know if it is included somewhere
|
||||
|
||||
MainWindow::MainWindow()
|
||||
{
|
||||
@@ -15,7 +16,7 @@ MainWindow::MainWindow()
|
||||
QWidget* w = 0;
|
||||
ph = unique_ptr<PasswordManagementWindow>{new PasswordManagementWindow};
|
||||
kh = unique_ptr<KeyManagementWindow>{new KeyManagementWindow{w, mw, ph.get()}};
|
||||
sf = unique_ptr<SaveFile>{new SaveFile};
|
||||
sf = unique_ptr<SaveFile>{new SaveFile{w, mw}};
|
||||
setupMainWindow();
|
||||
}
|
||||
|
||||
@@ -115,47 +116,14 @@ void MainWindow::switchControls(const bool enabled)
|
||||
void MainWindow::requestFilename()
|
||||
{
|
||||
std::cout<<"Start"<<std::endl;
|
||||
//sf.get()->show();
|
||||
SaveFile* sfo = new SaveFile{};
|
||||
sfo->show();
|
||||
//sfo->quit();
|
||||
sf.get()->show();
|
||||
std::cout<<"End"<<std::endl;
|
||||
}
|
||||
|
||||
/*
|
||||
* February 26, 2018
|
||||
*
|
||||
* Work on asking the user to enter a filename
|
||||
*
|
||||
* Update: February 27, 2018
|
||||
*
|
||||
* Continue working on asking the user for a filename.
|
||||
* I got it working so the controls that are related to
|
||||
* passwords are disabled. What needs to be done is
|
||||
* have it so that the password is not encrypted until
|
||||
* the button for confirming the password filename is
|
||||
* clicked. Might have to create a helper function
|
||||
* for the encryptPassword function
|
||||
*/
|
||||
void MainWindow::encryptPassword()
|
||||
{
|
||||
requestFilename();
|
||||
switchControlEnabling();
|
||||
/**
|
||||
|
||||
QString passwordToEncrypt{textForCryption.get()->toPlainText()}, keyForEncryption{selectionBox.get()->currentText()};
|
||||
auto passwordToEncryptString = passwordToEncrypt.toStdString(), keyForEncryptionString = FolderStructure::keyDirectory+keyForEncryption.toStdString();
|
||||
std::cout<<"Generated filename that contains encrypted password: "<<passwordToEncryptString<<std::endl;
|
||||
auto strKeyFilename = keyForEncryption.toStdString();
|
||||
Password<> pass{};
|
||||
Key<> k;
|
||||
pass.setupDecryptedMessage(passwordToEncryptString);
|
||||
k.setupFilename(strKeyFilename);
|
||||
|
||||
Encryption ec2{pass, k};
|
||||
std::cout<<"Encrypted"<<std::endl;
|
||||
ph.get()->populatePass();
|
||||
*/
|
||||
}
|
||||
void MainWindow::keyManagementWindow() { kh.get()->show(); }
|
||||
void MainWindow::passwordManageWindow() { ph.get()->show(); }
|
||||
@@ -174,3 +142,21 @@ void MainWindow::activateButton()
|
||||
if (content.size()>0 && selectionBox.get()->count()>0) actionButton.get()->setEnabled(true);
|
||||
else actionButton.get()->setEnabled(false);
|
||||
}
|
||||
void MainWindow::processEncryption()
|
||||
{
|
||||
QString passwordToEncrypt{textForCryption.get()->toPlainText()}, keyForEncryption{selectionBox.get()->currentText()};
|
||||
auto passwordToEncryptString = passwordToEncrypt.toStdString(), keyForEncryptionString = FolderStructure::keyDirectory+keyForEncryption.toStdString();
|
||||
std::cout<<"Generated filename that contains encrypted password: "<<passwordToEncryptString<<std::endl;
|
||||
auto strKeyFilename = keyForEncryption.toStdString();
|
||||
Password<> pass{SaveFile::filenameStr};
|
||||
cout << "Password filename: " << pass.passwordFilename() << endl;
|
||||
Key<> k;
|
||||
pass.setupDecryptedMessage(passwordToEncryptString);
|
||||
k.setupFilename(strKeyFilename);
|
||||
|
||||
Encryption ec2{pass, k};
|
||||
std::cout<<"Encrypted"<<std::endl;
|
||||
ph.get()->populatePass();
|
||||
|
||||
switchControlEnabling();
|
||||
}
|
||||
|
||||
+6
-2
@@ -10,11 +10,14 @@
|
||||
#include<QAction>
|
||||
#include<QDockWidget>
|
||||
#include<QWidget>
|
||||
#include"KeyManagementWindow.h"
|
||||
#include"PasswordManagementWindow.h"
|
||||
#include"CommonWindow.h"
|
||||
#include"KeyManagementWindow.h"
|
||||
#include"SaveFile.h"
|
||||
#include"PasswordManagementWindow.h"
|
||||
|
||||
class KeyManagementWindow;
|
||||
class PasswordManagementWindow;
|
||||
class SaveFile;
|
||||
|
||||
|
||||
class MainWindow : public QMainWindow, public CommonWindow
|
||||
@@ -25,6 +28,7 @@ public:
|
||||
~MainWindow() = default;
|
||||
|
||||
void refreshComboBox();
|
||||
void processEncryption();
|
||||
signals:
|
||||
private slots:
|
||||
void encryptPassword();
|
||||
|
||||
@@ -15,7 +15,7 @@ CXX = g++
|
||||
DEFINES = -DQT_DEPRECATED_WARNINGS -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB
|
||||
CFLAGS = -pipe -O2 -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -Wall -W -D_REENTRANT -fPIC $(DEFINES)
|
||||
CXXFLAGS = -pipe -O2 -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -Wall -W -D_REENTRANT -fPIC $(DEFINES)
|
||||
INCPATH = -I. -I. -isystem /usr/include/qt -isystem /usr/include/qt/QtWidgets -isystem /usr/include/qt/QtGui -isystem /usr/include/qt/QtCore -I. -isystem /usr/include/libdrm -I/usr/lib/qt/mkspecs/linux-g++ -I "/usr/include/boost"
|
||||
INCPATH = -I. -I. -isystem /usr/include/qt -isystem /usr/include/qt/QtWidgets -isystem /usr/include/qt/QtGui -isystem /usr/include/qt/QtCore -I. -isystem /usr/include/libdrm -I/usr/lib/qt/mkspecs/linux-g++ -I /usr/include/boost
|
||||
QMAKE = /usr/bin/qmake
|
||||
DEL_FILE = rm -f
|
||||
CHK_DIR_EXISTS= test -d
|
||||
@@ -35,10 +35,10 @@ MOVE = mv -f
|
||||
TAR = tar -cf
|
||||
COMPRESS = gzip -9f
|
||||
DISTNAME = PasswordEncryption1.0.0
|
||||
DISTDIR = /home/monde/Programming/C++/PasswordEncryption/.tmp/PasswordEncryption1.0.0
|
||||
DISTDIR = /home/flueric/Programming/C++/PasswordEncryption/.tmp/PasswordEncryption1.0.0
|
||||
LINK = g++
|
||||
LFLAGS = -Wl,-O1 -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now
|
||||
LIBS = $(SUBLIBS) -lQt5Widgets -lQt5Gui -lQt5Core -lGL -lpthread -L "/usr/include/boost" -lboost_filesystem -lboost_system
|
||||
LIBS = $(SUBLIBS) -lQt5Widgets -lQt5Gui -lQt5Core -lGL -lpthread -L "/usr/include/boost" -lboost_system -lboost_filesystem
|
||||
AR = ar cqs
|
||||
RANLIB =
|
||||
SED = sed
|
||||
@@ -137,7 +137,6 @@ DIST = /usr/lib/qt/mkspecs/features/spec_pre.prf \
|
||||
/usr/lib/qt/mkspecs/features/qt_config.prf \
|
||||
/usr/lib/qt/mkspecs/linux-g++/qmake.conf \
|
||||
/usr/lib/qt/mkspecs/features/spec_post.prf \
|
||||
.qmake.stash \
|
||||
/usr/lib/qt/mkspecs/features/exclusive_builds.prf \
|
||||
/usr/lib/qt/mkspecs/features/toolchain.prf \
|
||||
/usr/lib/qt/mkspecs/features/default_pre.prf \
|
||||
@@ -255,7 +254,6 @@ Makefile: PasswordEncryption.pro /usr/lib/qt/mkspecs/linux-g++/qmake.conf /usr/l
|
||||
/usr/lib/qt/mkspecs/features/qt_config.prf \
|
||||
/usr/lib/qt/mkspecs/linux-g++/qmake.conf \
|
||||
/usr/lib/qt/mkspecs/features/spec_post.prf \
|
||||
.qmake.stash \
|
||||
/usr/lib/qt/mkspecs/features/exclusive_builds.prf \
|
||||
/usr/lib/qt/mkspecs/features/toolchain.prf \
|
||||
/usr/lib/qt/mkspecs/features/default_pre.prf \
|
||||
@@ -335,7 +333,6 @@ Makefile: PasswordEncryption.pro /usr/lib/qt/mkspecs/linux-g++/qmake.conf /usr/l
|
||||
/usr/lib/qt/mkspecs/features/qt_config.prf:
|
||||
/usr/lib/qt/mkspecs/linux-g++/qmake.conf:
|
||||
/usr/lib/qt/mkspecs/features/spec_post.prf:
|
||||
.qmake.stash:
|
||||
/usr/lib/qt/mkspecs/features/exclusive_builds.prf:
|
||||
/usr/lib/qt/mkspecs/features/toolchain.prf:
|
||||
/usr/lib/qt/mkspecs/features/default_pre.prf:
|
||||
@@ -427,7 +424,7 @@ moc_KeyManagementWindow.cpp: CommonWindow.h \
|
||||
KeyManagementWindow.h \
|
||||
moc_predefs.h \
|
||||
/usr/bin/moc
|
||||
/usr/bin/moc $(DEFINES) --include ./moc_predefs.h -I/usr/lib/qt/mkspecs/linux-g++ -I/home/monde/Programming/C++/PasswordEncryption -I/home/monde/Programming/C++/PasswordEncryption -I/usr/include/qt -I/usr/include/qt/QtWidgets -I/usr/include/qt/QtGui -I/usr/include/qt/QtCore -I/usr/include/c++/7.3.0 -I/usr/include/c++/7.3.0/x86_64-pc-linux-gnu -I/usr/include/c++/7.3.0/backward -I/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/include -I/usr/local/include -I/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/include-fixed -I/usr/include KeyManagementWindow.h -o moc_KeyManagementWindow.cpp
|
||||
/usr/bin/moc $(DEFINES) --include ./moc_predefs.h -I/usr/lib/qt/mkspecs/linux-g++ -I/home/flueric/Programming/C++/PasswordEncryption -I/home/flueric/Programming/C++/PasswordEncryption -I/usr/include/qt -I/usr/include/qt/QtWidgets -I/usr/include/qt/QtGui -I/usr/include/qt/QtCore -I/usr/include/c++/7.3.1 -I/usr/include/c++/7.3.1/x86_64-pc-linux-gnu -I/usr/include/c++/7.3.1/backward -I/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.1/include -I/usr/local/include -I/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.1/include-fixed -I/usr/include KeyManagementWindow.h -o moc_KeyManagementWindow.cpp
|
||||
|
||||
moc_MainWindow.cpp: KeyManagementWindow.h \
|
||||
CommonWindow.h \
|
||||
@@ -447,7 +444,7 @@ moc_MainWindow.cpp: KeyManagementWindow.h \
|
||||
MainWindow.h \
|
||||
moc_predefs.h \
|
||||
/usr/bin/moc
|
||||
/usr/bin/moc $(DEFINES) --include ./moc_predefs.h -I/usr/lib/qt/mkspecs/linux-g++ -I/home/monde/Programming/C++/PasswordEncryption -I/home/monde/Programming/C++/PasswordEncryption -I/usr/include/qt -I/usr/include/qt/QtWidgets -I/usr/include/qt/QtGui -I/usr/include/qt/QtCore -I/usr/include/c++/7.3.0 -I/usr/include/c++/7.3.0/x86_64-pc-linux-gnu -I/usr/include/c++/7.3.0/backward -I/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/include -I/usr/local/include -I/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/include-fixed -I/usr/include MainWindow.h -o moc_MainWindow.cpp
|
||||
/usr/bin/moc $(DEFINES) --include ./moc_predefs.h -I/usr/lib/qt/mkspecs/linux-g++ -I/home/flueric/Programming/C++/PasswordEncryption -I/home/flueric/Programming/C++/PasswordEncryption -I/usr/include/qt -I/usr/include/qt/QtWidgets -I/usr/include/qt/QtGui -I/usr/include/qt/QtCore -I/usr/include/c++/7.3.1 -I/usr/include/c++/7.3.1/x86_64-pc-linux-gnu -I/usr/include/c++/7.3.1/backward -I/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.1/include -I/usr/local/include -I/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.1/include-fixed -I/usr/include MainWindow.h -o moc_MainWindow.cpp
|
||||
|
||||
moc_PasswordManagementWindow.cpp: CommonWindow.h \
|
||||
ViewingWindow.h \
|
||||
@@ -455,14 +452,14 @@ moc_PasswordManagementWindow.cpp: CommonWindow.h \
|
||||
PasswordManagementWindow.h \
|
||||
moc_predefs.h \
|
||||
/usr/bin/moc
|
||||
/usr/bin/moc $(DEFINES) --include ./moc_predefs.h -I/usr/lib/qt/mkspecs/linux-g++ -I/home/monde/Programming/C++/PasswordEncryption -I/home/monde/Programming/C++/PasswordEncryption -I/usr/include/qt -I/usr/include/qt/QtWidgets -I/usr/include/qt/QtGui -I/usr/include/qt/QtCore -I/usr/include/c++/7.3.0 -I/usr/include/c++/7.3.0/x86_64-pc-linux-gnu -I/usr/include/c++/7.3.0/backward -I/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/include -I/usr/local/include -I/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/include-fixed -I/usr/include PasswordManagementWindow.h -o moc_PasswordManagementWindow.cpp
|
||||
/usr/bin/moc $(DEFINES) --include ./moc_predefs.h -I/usr/lib/qt/mkspecs/linux-g++ -I/home/flueric/Programming/C++/PasswordEncryption -I/home/flueric/Programming/C++/PasswordEncryption -I/usr/include/qt -I/usr/include/qt/QtWidgets -I/usr/include/qt/QtGui -I/usr/include/qt/QtCore -I/usr/include/c++/7.3.1 -I/usr/include/c++/7.3.1/x86_64-pc-linux-gnu -I/usr/include/c++/7.3.1/backward -I/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.1/include -I/usr/local/include -I/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.1/include-fixed -I/usr/include PasswordManagementWindow.h -o moc_PasswordManagementWindow.cpp
|
||||
|
||||
moc_SaveFile.cpp: CommonWindow.h \
|
||||
ViewingWindow.h \
|
||||
SaveFile.h \
|
||||
moc_predefs.h \
|
||||
/usr/bin/moc
|
||||
/usr/bin/moc $(DEFINES) --include ./moc_predefs.h -I/usr/lib/qt/mkspecs/linux-g++ -I/home/monde/Programming/C++/PasswordEncryption -I/home/monde/Programming/C++/PasswordEncryption -I/usr/include/qt -I/usr/include/qt/QtWidgets -I/usr/include/qt/QtGui -I/usr/include/qt/QtCore -I/usr/include/c++/7.3.0 -I/usr/include/c++/7.3.0/x86_64-pc-linux-gnu -I/usr/include/c++/7.3.0/backward -I/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/include -I/usr/local/include -I/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/include-fixed -I/usr/include SaveFile.h -o moc_SaveFile.cpp
|
||||
/usr/bin/moc $(DEFINES) --include ./moc_predefs.h -I/usr/lib/qt/mkspecs/linux-g++ -I/home/flueric/Programming/C++/PasswordEncryption -I/home/flueric/Programming/C++/PasswordEncryption -I/usr/include/qt -I/usr/include/qt/QtWidgets -I/usr/include/qt/QtGui -I/usr/include/qt/QtCore -I/usr/include/c++/7.3.1 -I/usr/include/c++/7.3.1/x86_64-pc-linux-gnu -I/usr/include/c++/7.3.1/backward -I/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.1/include -I/usr/local/include -I/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.1/include-fixed -I/usr/include SaveFile.h -o moc_SaveFile.cpp
|
||||
|
||||
compiler_moc_objc_header_make_all:
|
||||
compiler_moc_objc_header_clean:
|
||||
|
||||
@@ -25,6 +25,7 @@ public:
|
||||
void setupEncryptedMessage(const S&);
|
||||
void setupDecryptedMessage(const S&);
|
||||
void setupPasswordFilename();
|
||||
void setupPasswordFilename(const S&);
|
||||
void setupDate();
|
||||
S retrieveEncryptedMessage() const;
|
||||
S retrieveDecryptedMessage() const;
|
||||
@@ -59,6 +60,14 @@ void Password<S>::setupPasswordFilename()
|
||||
}
|
||||
}
|
||||
template<typename S>
|
||||
void Password<S>::setupPasswordFilename(const S& fin)
|
||||
{
|
||||
for (auto passwordNameDoesNotExist = true; passwordNameDoesNotExist; passwordNameDoesNotExist = repetitive())
|
||||
{
|
||||
filename.assign(fin);
|
||||
}
|
||||
}
|
||||
template<typename S>
|
||||
S Password<S>::retrieveEncryptedMessage() const { return encryptedMessage; }
|
||||
template<typename S>
|
||||
S Password<S>::retrieveDecryptedMessage() const { return decryptedMessage; }
|
||||
|
||||
+12
-4
@@ -1,9 +1,11 @@
|
||||
#include<QString>
|
||||
#include"SaveFile.h"
|
||||
|
||||
SaveFile::SaveFile(QWidget* parent) : QDialog(parent)
|
||||
{
|
||||
setupWindow();
|
||||
}
|
||||
string SaveFile::filenameStr = "default.txt";
|
||||
|
||||
SaveFile::SaveFile(QWidget* parent) : QDialog(parent) { setupWindow(); }
|
||||
SaveFile::SaveFile(QWidget* parent, MainWindow* mw) : QDialog(parent), mw(mw) { setupWindow(); }
|
||||
|
||||
|
||||
void SaveFile::setupWindow()
|
||||
{
|
||||
@@ -34,5 +36,11 @@ void SaveFile::connections()
|
||||
}
|
||||
void SaveFile::saveFileAs()
|
||||
{
|
||||
QString fs = filename.get()->text();
|
||||
filenameStr.assign(fs.toUtf8().constData());
|
||||
filenameStr.append(".txt");
|
||||
|
||||
mw.get()->processEncryption();
|
||||
|
||||
this->hide();
|
||||
}
|
||||
|
||||
+11
@@ -1,20 +1,31 @@
|
||||
#ifndef SAVEFILE_H_
|
||||
#define SAVEFILE_H_
|
||||
|
||||
#include<iostream>
|
||||
#include<string>
|
||||
#include"CommonWindow.h"
|
||||
#include"MainWindow.h"
|
||||
#include"ViewingWindow.h"
|
||||
|
||||
class MainWindow;
|
||||
|
||||
using namespace std;
|
||||
|
||||
class SaveFile : public QDialog, public CommonWindow, public ViewingWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
SaveFile(QWidget* parent = 0);
|
||||
explicit SaveFile(QWidget* parent = 0, MainWindow* mw = 0);
|
||||
static string filenameStr;
|
||||
private:
|
||||
void setupWindow();
|
||||
void connections();
|
||||
|
||||
unique_ptr<QLineEdit> filename;
|
||||
unique_ptr<QPushButton> saveIt;
|
||||
unique_ptr<MainWindow> mw;
|
||||
|
||||
private slots:
|
||||
void saveFileAs();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user