diff --git a/Decryption.cpp b/Decryption.cpp index 60f3f5f..8b0e7b3 100644 --- a/Decryption.cpp +++ b/Decryption.cpp @@ -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(); diff --git a/Encryption.cpp b/Encryption.cpp index 1f7f701..b574bba 100644 --- a/Encryption.cpp +++ b/Encryption.cpp @@ -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) { diff --git a/GeneratePasswordFileName.cpp b/GeneratePasswordFileName.cpp index a2bd25f..ee01341 100644 --- a/GeneratePasswordFileName.cpp +++ b/GeneratePasswordFileName.cpp @@ -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()); diff --git a/KeyManagementWindow.h b/KeyManagementWindow.h index 46ccd06..df52485 100644 --- a/KeyManagementWindow.h +++ b/KeyManagementWindow.h @@ -9,6 +9,7 @@ #include"ViewingWindow.h" class MainWindow; +class PasswordManagementWindow; class KeyManagementWindow : public QDialog, public CommonWindow, public ViewingWindow { diff --git a/MainWindow.cpp b/MainWindow.cpp index 69a4d68..cfebfa7 100644 --- a/MainWindow.cpp +++ b/MainWindow.cpp @@ -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{new PasswordManagementWindow}; kh = unique_ptr{new KeyManagementWindow{w, mw, ph.get()}}; - sf = unique_ptr{new SaveFile}; + sf = unique_ptr{new SaveFile{w, mw}}; setupMainWindow(); } @@ -115,47 +116,14 @@ void MainWindow::switchControls(const bool enabled) void MainWindow::requestFilename() { std::cout<<"Start"<show(); - SaveFile* sfo = new SaveFile{}; - sfo->show(); - //sfo->quit(); + sf.get()->show(); std::cout<<"End"<toPlainText()}, keyForEncryption{selectionBox.get()->currentText()}; - auto passwordToEncryptString = passwordToEncrypt.toStdString(), keyForEncryptionString = FolderStructure::keyDirectory+keyForEncryption.toStdString(); - std::cout<<"Generated filename that contains encrypted password: "< pass{}; - Key<> k; - pass.setupDecryptedMessage(passwordToEncryptString); - k.setupFilename(strKeyFilename); - - Encryption ec2{pass, k}; - std::cout<<"Encrypted"<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: "< pass{SaveFile::filenameStr}; + cout << "Password filename: " << pass.passwordFilename() << endl; + Key<> k; + pass.setupDecryptedMessage(passwordToEncryptString); + k.setupFilename(strKeyFilename); + + Encryption ec2{pass, k}; + std::cout<<"Encrypted"<populatePass(); + + switchControlEnabling(); +} diff --git a/MainWindow.h b/MainWindow.h index d3308da..c33c085 100644 --- a/MainWindow.h +++ b/MainWindow.h @@ -10,11 +10,14 @@ #include #include #include -#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(); diff --git a/Makefile b/Makefile index 78d3246..8e75917 100644 --- a/Makefile +++ b/Makefile @@ -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: diff --git a/Password.h b/Password.h index 4b30557..6a56aa4 100644 --- a/Password.h +++ b/Password.h @@ -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::setupPasswordFilename() } } template +void Password::setupPasswordFilename(const S& fin) +{ + for (auto passwordNameDoesNotExist = true; passwordNameDoesNotExist; passwordNameDoesNotExist = repetitive()) + { + filename.assign(fin); + } +} +template S Password::retrieveEncryptedMessage() const { return encryptedMessage; } template S Password::retrieveDecryptedMessage() const { return decryptedMessage; } diff --git a/SaveFile.cpp b/SaveFile.cpp index deb9c67..08b48e9 100644 --- a/SaveFile.cpp +++ b/SaveFile.cpp @@ -1,9 +1,11 @@ +#include #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(); } diff --git a/SaveFile.h b/SaveFile.h index 63ba544..62e8cb0 100644 --- a/SaveFile.h +++ b/SaveFile.h @@ -1,20 +1,31 @@ #ifndef SAVEFILE_H_ #define SAVEFILE_H_ +#include +#include #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 filename; unique_ptr saveIt; + unique_ptr mw; + private slots: void saveFileAs(); };