Skip to content

Instantly share code, notes, and snippets.

@SamuelTulach
Created August 12, 2020 18:53
Show Gist options
  • Save SamuelTulach/833af44c38f19b72ab7f618539d643a1 to your computer and use it in GitHub Desktop.
Save SamuelTulach/833af44c38f19b72ab7f618539d643a1 to your computer and use it in GitHub Desktop.
#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