This repository has been archived on 2026-07-02. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
PasswordEncryption/Encryption.cpp
T
2017-04-25 13:05:01 -05:00

48 lines
1.0 KiB
C++

#include <ios>
#include <iostream>
#include <string>
#include "Encryption.h"
#include "GenerateKeys.h"
Encryption::Encryption()
{
}
Encryption::Encryption(const std::string& message)
{
this->message = message;
}
void Encryption::setEncryptedMessage(const std::string& encryptedMessage)
{
this->encryptedMessage = encryptedMessage;
}
void Encryption::encryptMessage()
{
int numberOfNewLines{0};
GenerateKeys gk{};
ioEvent.open("encryptedFile.txt", std::ios::out);
//std::cout << "String to encrypt: " << message << std::endl;
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)
{
ioEvent << gk.encryptedCharacters[message.at(indexOfString)];
encryptedMessage += (gk.encryptedCharacters[message.at(indexOfString)]);
}
setEncryptedMessage(encryptedMessage);
ioEvent.close();
}
std::string Encryption::getEncryptedMessage() const
{
return encryptedMessage;
}