25 lines
524 B
C++
25 lines
524 B
C++
#pragma once
|
|
#include <cstdint>
|
|
#include "buffer.h"
|
|
|
|
struct evp_cipher_ctx_st;
|
|
typedef struct evp_cipher_ctx_st EVP_CIPHER_CTX;
|
|
|
|
|
|
class Cryptography
|
|
{
|
|
public:
|
|
Cryptography(const char* password, size_t size);
|
|
~Cryptography();
|
|
bool encrypt(Buffer* plain, Buffer* encrypted);
|
|
bool decrypt(Buffer* encrypted, Buffer* decrypted);
|
|
|
|
private:
|
|
uint8_t key[32] = { 0 };
|
|
uint8_t iv[16] = { 0 };
|
|
EVP_CIPHER_CTX* ctx = nullptr;
|
|
|
|
bool generate_key_and_iv_from_password(const char* password, size_t size);
|
|
bool handleErrors();
|
|
};
|