Refractoring code and adding memory management

This commit is contained in:
Flueric
2017-06-20 18:33:38 -05:00
parent e38f10e759
commit d82b286ec9
13 changed files with 135 additions and 1796 deletions
+8 -16
View File
@@ -1,40 +1,32 @@
#include<ios>
#include<iostream>
#include<fstream>
#include<string>
#include"Encryption.h"
#include"GenerateKeys.h"
Encryption::Encryption()
{ }
Encryption::~Encryption()
{ }
Encryption::Encryption(const std::string& message)
{ this->message = message; }
{
this->message = message;
encryptMessage();
}
void Encryption::setEncryptedMessage(const std::string& encryptedMessage)
{ this->encryptedMessage = encryptedMessage; }
void Encryption::encryptMessage()
{
auto numberOfNewLines = 0;
GenerateKeys gk{};
std::fstream ioEvent{};
ioEvent.open("encryptedFile.txt", std::ios::out);
for (auto index = 0; index != message.size(); ++index)
{
char stringIndex = message.at(index);
if (stringIndex == '\n')
++numberOfNewLines;
}
for (auto indexOfString = 0; indexOfString!=message.size(); ++indexOfString)
for (auto indexOfString = 0u; indexOfString!=message.size(); ++indexOfString)
{
ioEvent << gk.encryptedCharacters[message.at(indexOfString)];
encryptedMessage += (gk.encryptedCharacters[message.at(indexOfString)]);
}
setEncryptedMessage(encryptedMessage);
this->encryptedMessage = encryptedMessage;
ioEvent.close();
}