Issue #2 added feature to generate a new default key

This commit is contained in:
amazing-username
2017-04-28 16:01:22 -05:00
parent 222f0c607b
commit e38f10e759
13 changed files with 161 additions and 144 deletions
+17 -34
View File
@@ -1,24 +1,24 @@
#include <iostream>
#include<iostream>
#include<sstream>
#include <ios>
#include <string>
#include<ios>
#include<string>
#include "Decryption.h"
#include "GenerateKeys.h"
#include"Decryption.h"
#include"GenerateKeys.h"
Decryption::Decryption()
{
}
{ }
Decryption::~Decryption()
{ }
Decryption::Decryption(const std::string& message)
{
this->message = message;
}
{ this->message = message; }
void Decryption::setDecryptedMessage(const std::string& message)
{
this->decryptedMessage = message;
}
{ this->decryptedMessage = message; }
void Decryption::decryptMessage()
{
GenerateKeys gk{};
@@ -31,7 +31,7 @@ void Decryption::decryptMessage()
ioEvent.close();
for (auto indexOfChar = 0; indexOfChar<messageToBeDecrypted.size(); indexOfChar+=5)
for (auto indexOfChar = 0u; indexOfChar<messageToBeDecrypted.size(); indexOfChar+=5)
{
char cryptedKey[5]{};
for (auto index = 0; index!=5; ++index)
@@ -41,36 +41,19 @@ void Decryption::decryptMessage()
}
decryptedMessage += gk.decryptedCharacters[cstringToString(cryptedKey, 5)];
}
//std::cout << "Decrypted Message: " << decryptedMessage << std::endl;
setDecryptedMessage(decryptedMessage);
}
std::string Decryption::getDecryptedMessage() const
{
return decryptedMessage;
}
{ return decryptedMessage; }
std::string Decryption::cstringToString(char tmp[], const int& SIZE)
{
std::string tmpString{};
std::stringstream cToS{};
for (auto index = 0; index!=5; ++index)
{
for (auto index = 0; index!=SIZE; ++index)
cToS << tmp[index];
}
cToS >> tmpString;
return tmpString;
}
unsigned short getTwoNumberedKey(unsigned short& number)
{
std::string wholeNumber{std::to_string(number)};
char hundred[] = {wholeNumber.at(0)};
char ten[] = {wholeNumber.at(1)};
char one[] {wholeNumber.at(2)};
unsigned short hundread, tenN, oneN;
hundread = number;
}