Added more controls to the skeleton, added a base class, updated some elements
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
#include "Cryption.h"
|
||||
|
||||
Cryption::Cryption()
|
||||
{
|
||||
|
||||
}
|
||||
Cryption::Cryption(const std::string& message)
|
||||
{
|
||||
this->message = message;
|
||||
}
|
||||
|
||||
|
||||
void Cryption::setMessage(const std::string& message)
|
||||
{
|
||||
this->message = message;
|
||||
}
|
||||
|
||||
|
||||
std::string Cryption::getMessage() const
|
||||
{
|
||||
return message;
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
#ifndef CRYPTION_H
|
||||
#define CRYPTION_H
|
||||
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
|
||||
class Cryption
|
||||
{
|
||||
public:
|
||||
Cryption();
|
||||
Cryption(const std::string&);
|
||||
|
||||
void setMessage(const std::string&);
|
||||
|
||||
std::string getMessage() const;
|
||||
|
||||
protected:
|
||||
std::string message;
|
||||
std::fstream ioEvent;
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
#endif
|
||||
+7
-13
@@ -9,28 +9,28 @@ Decryption::Decryption()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void Decryption::setMessage(const std::string message)
|
||||
Decryption::Decryption(const std::string& message)
|
||||
{
|
||||
this->message = message;
|
||||
}
|
||||
|
||||
|
||||
void Decryption::decryptMessage()
|
||||
{
|
||||
GenerateKeys gk;
|
||||
|
||||
readFromFile.open("encryptedFile.txt", std::ios::in);
|
||||
ioEvent.open("encryptedFile.txt", std::ios::in);
|
||||
|
||||
std::string messageToBeDecrypted, decryptedMessage;
|
||||
|
||||
while(!readFromFile.eof())
|
||||
while(!ioEvent.eof())
|
||||
{
|
||||
char whiteSpace = static_cast<char>(32);
|
||||
//std::cout << "Am I stuck?" << std::endl;
|
||||
getline(readFromFile, messageToBeDecrypted, whiteSpace);
|
||||
getline(ioEvent, messageToBeDecrypted, whiteSpace);
|
||||
}
|
||||
|
||||
readFromFile.close();
|
||||
ioEvent.close();
|
||||
|
||||
unsigned short encryptedTwoKey = 2;
|
||||
unsigned short beginningOfAlphabetLowerCase = 97;
|
||||
@@ -67,9 +67,3 @@ void Decryption::decryptMessage()
|
||||
}
|
||||
setMessage(decryptedMessage);
|
||||
}
|
||||
|
||||
|
||||
std::string Decryption::getMessage() const
|
||||
{
|
||||
return message;
|
||||
}
|
||||
|
||||
+4
-6
@@ -4,20 +4,18 @@
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
|
||||
class Decryption
|
||||
#include "Cryption.h"
|
||||
|
||||
class Decryption : public Cryption
|
||||
{
|
||||
public:
|
||||
|
||||
Decryption();
|
||||
Decryption(const std::string&);
|
||||
|
||||
void setMessage(const std::string);
|
||||
void decryptMessage();
|
||||
|
||||
std::string getMessage() const;
|
||||
|
||||
private:
|
||||
std::fstream readFromFile;
|
||||
std::string message;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -9,9 +9,10 @@ QT += widgets
|
||||
INCLUDEPATH += .
|
||||
|
||||
# Input
|
||||
HEADERS += Decryption.h Encryption.h GenerateKeys.h MessagingControls.h
|
||||
HEADERS += Decryption.h Encryption.h GenerateKeys.h MessagingControls.h Cryption.h
|
||||
SOURCES += Decryption.cpp \
|
||||
Encryption.cpp \
|
||||
Cryption.cpp \
|
||||
GenerateKeys.cpp \
|
||||
Main.cpp \
|
||||
MessagingControls.cpp
|
||||
|
||||
+6
-12
@@ -7,29 +7,23 @@ Encryption::Encryption()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void Encryption::setMessage(const std::string message)
|
||||
Encryption::Encryption(const std::string& message)
|
||||
{
|
||||
this->message = message;
|
||||
}
|
||||
|
||||
|
||||
void Encryption::encryptMessage()
|
||||
{
|
||||
GenerateKeys* gk = new GenerateKeys;
|
||||
writeToFile.open("encryptedFile.txt", std::ios::out);
|
||||
ioEvent.open("encryptedFile.txt", std::ios::out);
|
||||
|
||||
for (unsigned short indexOfString = 0; indexOfString < message.size(); indexOfString++)
|
||||
{
|
||||
writeToFile << gk->encryptedCharacters[message.at(indexOfString)];
|
||||
ioEvent << gk->encryptedCharacters[message.at(indexOfString)];
|
||||
}
|
||||
|
||||
writeToFile.close();
|
||||
ioEvent.close();
|
||||
|
||||
delete gk;
|
||||
}
|
||||
|
||||
|
||||
std::string Encryption::getMessage() const
|
||||
{
|
||||
return message;
|
||||
}
|
||||
|
||||
+4
-6
@@ -4,20 +4,18 @@
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
|
||||
class Encryption
|
||||
#include "Cryption.h"
|
||||
|
||||
class Encryption : public Cryption
|
||||
{
|
||||
public:
|
||||
|
||||
Encryption();
|
||||
Encryption(const std::string&);
|
||||
|
||||
void setMessage(const std::string);
|
||||
void encryptMessage();
|
||||
|
||||
std::string getMessage() const;
|
||||
|
||||
private:
|
||||
std::fstream writeToFile;
|
||||
std::string message;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
#include <iostream>
|
||||
#include <QApplication>
|
||||
|
||||
#include "MessagingControls.h"
|
||||
|
||||
@@ -50,11 +50,13 @@ OBJECTS_DIR = ./
|
||||
|
||||
SOURCES = Decryption.cpp \
|
||||
Encryption.cpp \
|
||||
Cryption.cpp \
|
||||
GenerateKeys.cpp \
|
||||
Main.cpp \
|
||||
MessagingControls.cpp moc_MessagingControls.cpp
|
||||
OBJECTS = Decryption.o \
|
||||
Encryption.o \
|
||||
Cryption.o \
|
||||
GenerateKeys.o \
|
||||
Main.o \
|
||||
MessagingControls.o \
|
||||
@@ -167,8 +169,10 @@ DIST = /usr/lib/qt/mkspecs/features/spec_pre.prf \
|
||||
EncryptedMessaging.pro Decryption.h \
|
||||
Encryption.h \
|
||||
GenerateKeys.h \
|
||||
MessagingControls.h Decryption.cpp \
|
||||
MessagingControls.h \
|
||||
Cryption.h Decryption.cpp \
|
||||
Encryption.cpp \
|
||||
Cryption.cpp \
|
||||
GenerateKeys.cpp \
|
||||
Main.cpp \
|
||||
MessagingControls.cpp
|
||||
@@ -417,8 +421,8 @@ distdir: FORCE
|
||||
@test -d $(DISTDIR) || mkdir -p $(DISTDIR)
|
||||
$(COPY_FILE) --parents $(DIST) $(DISTDIR)/
|
||||
$(COPY_FILE) --parents /usr/lib/qt/mkspecs/features/data/dummy.cpp $(DISTDIR)/
|
||||
$(COPY_FILE) --parents Decryption.h Encryption.h GenerateKeys.h MessagingControls.h $(DISTDIR)/
|
||||
$(COPY_FILE) --parents Decryption.cpp Encryption.cpp GenerateKeys.cpp Main.cpp MessagingControls.cpp $(DISTDIR)/
|
||||
$(COPY_FILE) --parents Decryption.h Encryption.h GenerateKeys.h MessagingControls.h Cryption.h $(DISTDIR)/
|
||||
$(COPY_FILE) --parents Decryption.cpp Encryption.cpp Cryption.cpp GenerateKeys.cpp Main.cpp MessagingControls.cpp $(DISTDIR)/
|
||||
|
||||
|
||||
clean: compiler_clean
|
||||
@@ -473,20 +477,25 @@ compiler_clean: compiler_moc_predefs_clean compiler_moc_header_clean
|
||||
####### Compile
|
||||
|
||||
Decryption.o: Decryption.cpp Decryption.h \
|
||||
Cryption.h \
|
||||
GenerateKeys.h
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o Decryption.o Decryption.cpp
|
||||
|
||||
Encryption.o: Encryption.cpp Encryption.h \
|
||||
Cryption.h \
|
||||
GenerateKeys.h
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o Encryption.o Encryption.cpp
|
||||
|
||||
Cryption.o: Cryption.cpp Cryption.h
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o Cryption.o Cryption.cpp
|
||||
|
||||
GenerateKeys.o: GenerateKeys.cpp GenerateKeys.h
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o GenerateKeys.o GenerateKeys.cpp
|
||||
|
||||
Main.o: Main.cpp
|
||||
Main.o: Main.cpp MessagingControls.h
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o Main.o Main.cpp
|
||||
|
||||
MessagingControls.o: MessagingControls.cpp
|
||||
MessagingControls.o: MessagingControls.cpp MessagingControls.h
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o MessagingControls.o MessagingControls.cpp
|
||||
|
||||
moc_MessagingControls.o: moc_MessagingControls.cpp
|
||||
|
||||
+78
-48
@@ -1,7 +1,6 @@
|
||||
#include <QtGui>
|
||||
#include <QHBoxLayout>
|
||||
#include <QVBoxLayout>
|
||||
#include <QDockWidget>
|
||||
#include <QString>
|
||||
#include <iostream>
|
||||
|
||||
#include "MessagingControls.h"
|
||||
|
||||
@@ -10,49 +9,9 @@ MessagingControls::MessagingControls()
|
||||
/**
|
||||
* Initialize controls
|
||||
*/
|
||||
//QVBoxLayout* everything = new QVBoxLayout;
|
||||
cryptionChoice = true;
|
||||
|
||||
//menuStuff = new QMenuBar;
|
||||
//mainWindow = new QMainWindow;
|
||||
|
||||
lblOfEncryptedBox = new QLabel(tr("Message: "));
|
||||
|
||||
textToEncrypt = new QTextEdit;
|
||||
//encryptedBox = new QLineEdit;
|
||||
|
||||
encryptionButon = new QPushButton;
|
||||
|
||||
//Adding lbl and line edit
|
||||
//QHBoxLayout* lblAndLineEdit = new QHBoxLayout;
|
||||
//lblAndLineEdit->addWidget(lblOfEncryptedBox);
|
||||
//lblAndLineEdit->addWidget(textToEncrypt);
|
||||
|
||||
//Adding button
|
||||
//QHBoxLayout* button = new QHBoxLayout;
|
||||
//button->addWidget(encryptionButon);
|
||||
|
||||
//Add everything
|
||||
//everything->addLayout(menuStuff);
|
||||
//everything->addLayout(lblAndLineEdit);
|
||||
//everything->addLayout(button);
|
||||
|
||||
createMenus();
|
||||
|
||||
QDockWidget* lblAndArea = new QDockWidget(tr("Dock Widget"));
|
||||
lblAndArea->setWidget(textToEncrypt);
|
||||
//lblAndArea->setWidget(lblOfEncryptedBox);
|
||||
|
||||
addDockWidget(Qt::LeftDockWidgetArea, lblAndArea);
|
||||
|
||||
//mainWindow->addDockWidget(Qt::LeftDockWidgetArea, lblAndArea);
|
||||
//mainWindow->addDockWidget(lblAndArea);
|
||||
//mainWindow->addDockWidget(textToEncrypt);
|
||||
//mainWindow->addDockWidget(encryptionButon);
|
||||
|
||||
//setLayout(mainWindow);
|
||||
setWindowTitle("Encryption Messaging");
|
||||
setFixedHeight(300);
|
||||
setFixedWidth(400);
|
||||
setupMainWindow();
|
||||
}
|
||||
MessagingControls::~MessagingControls()
|
||||
{
|
||||
@@ -60,13 +19,47 @@ MessagingControls::~MessagingControls()
|
||||
* Delete pointer types
|
||||
*/
|
||||
delete lblOfEncryptedBox;
|
||||
delete encryptionButon;
|
||||
delete textToEncrypt;
|
||||
//delete encryptedBox;
|
||||
delete cryptionButon;
|
||||
delete textForCryption;
|
||||
|
||||
}
|
||||
|
||||
|
||||
void MessagingControls::setupMainWindow()
|
||||
{
|
||||
textForCryption = new QTextEdit;
|
||||
|
||||
|
||||
cryptionButon = new QPushButton(tr("XO"));
|
||||
cryptionSwitch = new QPushButton(tr("encrypt"));
|
||||
|
||||
|
||||
buttonLayout = new QVBoxLayout;
|
||||
buttonWidget = new QWidget;
|
||||
buttonDockWidget = new QDockWidget;
|
||||
buttonDockWidget->setWindowTitle(tr("Cryption Controls"));
|
||||
buttonLayout->addWidget(cryptionButon);
|
||||
buttonLayout->addWidget(cryptionSwitch);
|
||||
buttonWidget->setLayout(buttonLayout);
|
||||
buttonDockWidget->setWidget(buttonWidget);
|
||||
buttonDockWidget->setFeatures(QDockWidget::NoDockWidgetFeatures);
|
||||
setCentralWidget(buttonDockWidget);
|
||||
|
||||
QDockWidget* cryptionArea = new QDockWidget(tr("Cryption"));
|
||||
cryptionArea->setWidget(textForCryption);
|
||||
cryptionArea->setFeatures(QDockWidget::NoDockWidgetFeatures);
|
||||
addDockWidget(Qt::LeftDockWidgetArea, cryptionArea);
|
||||
|
||||
createMenus();
|
||||
|
||||
QObject::connect(closeApplication, SIGNAL(triggered()), this, SLOT(close()));
|
||||
QObject::connect(cryptionSwitch, SIGNAL(clicked()), this, SLOT(changeCryptionType()));
|
||||
QObject::connect(cryptionButon, SIGNAL(clicked()), this, SLOT(determineCryption()));
|
||||
|
||||
setWindowTitle("Encryption Decryption Messaging");
|
||||
setFixedHeight(mainWindowHeight);
|
||||
setFixedWidth(mainWindowWidth);
|
||||
}
|
||||
void MessagingControls::createMenus()
|
||||
{
|
||||
fileMenu = menuBar()->addMenu(tr("File"));
|
||||
@@ -78,5 +71,42 @@ void MessagingControls::createMenus()
|
||||
fileMenu->addAction(closeApplication);
|
||||
|
||||
editMenu->addAction(keyEdit);
|
||||
}
|
||||
|
||||
|
||||
void MessagingControls::changeCryptionType()
|
||||
{
|
||||
if (cryptionChoice)
|
||||
{
|
||||
cryptionSwitch->setText("decrypt");
|
||||
cryptionChoice = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
cryptionSwitch->setText("encrypt");
|
||||
cryptionChoice = true;
|
||||
}
|
||||
}
|
||||
void MessagingControls::determineCryption()
|
||||
{
|
||||
if (cryptionChoice)
|
||||
{
|
||||
/**
|
||||
* Decrypt Message
|
||||
*/
|
||||
}
|
||||
else
|
||||
{
|
||||
/**
|
||||
* Encrypt Message
|
||||
*/
|
||||
}
|
||||
//std::string s;
|
||||
//s = textForCryption->toPlainText().toStdString();
|
||||
//std::cout << s << std::endl;
|
||||
//QString* str = textForCryption->toPlainText();
|
||||
//s = str->toStdString();
|
||||
//s = static_cast<std::string>(textForCryption->toPlainText());
|
||||
//std::cout << textForCryption->toPlainText() << std::endl;
|
||||
|
||||
}
|
||||
|
||||
+26
-5
@@ -10,6 +10,9 @@
|
||||
#include <QMainWindow>
|
||||
#include <QMenu>
|
||||
#include <QAction>
|
||||
#include <QVBoxLayout>
|
||||
#include <QDockWidget>
|
||||
#include <QWidget>
|
||||
|
||||
class QLabel;
|
||||
class QLineEdit;
|
||||
@@ -27,24 +30,42 @@ public:
|
||||
MessagingControls();
|
||||
~MessagingControls();
|
||||
|
||||
|
||||
|
||||
signals:
|
||||
|
||||
|
||||
private slots:
|
||||
void changeCryptionType();
|
||||
void determineCryption();
|
||||
|
||||
private:
|
||||
void setupMainWindow();
|
||||
void createMenus();
|
||||
|
||||
QLineEdit* encryptedBox;
|
||||
QVBoxLayout* buttonLayout;
|
||||
|
||||
QWidget* buttonWidget;
|
||||
|
||||
QDockWidget* buttonDockWidget;
|
||||
QDockWidget* cryptionArea;
|
||||
|
||||
QLabel* lblOfEncryptedBox;
|
||||
QTextEdit* textToEncrypt;
|
||||
QPushButton* encryptionButon;
|
||||
QLineEdit* encryptedBox;
|
||||
|
||||
QTextEdit* textForCryption;
|
||||
QTextEdit* textToDecrypt;
|
||||
|
||||
QPushButton* cryptionButon;
|
||||
QPushButton* cryptionSwitch;
|
||||
|
||||
QMenu* fileMenu;
|
||||
QMenu* editMenu;
|
||||
QAction* closeApplication;
|
||||
QAction* keyEdit;
|
||||
|
||||
unsigned short mainWindowHeight = 450;
|
||||
unsigned short mainWindowWidth = 550;
|
||||
|
||||
bool cryptionChoice;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user