#pragma once
#include <cstdint>

struct evp_cipher_ctx_st;
typedef struct evp_cipher_ctx_st EVP_CIPHER_CTX;

class Buffer;

class Cryptography
{
public:
	Cryptography(const char* password, size_t size);
	~Cryptography();
	bool encrypt(Buffer* plain, Buffer* encrypted);
	bool decrypt(Buffer* encrypted, Buffer* decrypted);
	bool generate_key_and_iv_from_password(const char* password, size_t size);

private:
	uint8_t key[32] = { 0 };
	uint8_t iv[16] = { 0 };
	EVP_CIPHER_CTX* ctx = nullptr;
	bool handleErrors();
};
