Created
August 12, 2020 18:53
-
-
Save SamuelTulach/833af44c38f19b72ab7f618539d643a1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Windows.h> | |
#include <vector> | |
#include <string> | |
#include "shared.h" | |
#include "AES.h" | |
#include "encryption.h" | |
#include "base64.h" | |
std::string Encryption::Encrypt(Packet packet) | |
{ | |
unsigned outLength = 0; | |
auto* encrypted = aes.EncryptECB(reinterpret_cast<unsigned char*>(&packet), sizeof(Packet), key, outLength); | |
auto base64 = Base64::encode(encrypted, outLength); | |
return base64; | |
} | |
Packet Encryption::Decrypt(std::string input) | |
{ | |
auto base64 = Base64::decode(input); | |
auto* decrypted = aes.DecryptECB(base64.data(), base64.size(), key); | |
Packet packet; | |
memcpy(&packet, decrypted, sizeof(packet)); | |
return packet; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment