Refractoring code and adding memory management
This commit is contained in:
+8
-16
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user