-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaes_enc_dec.h
82 lines (60 loc) · 1.77 KB
/
aes_enc_dec.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/*
-- ----------------------------------------------------------------------
-- Project: Custom dll for piotec
--
-- Author: Hamza Qureshi
--
-- File name: aes_enc_dec_class.h
--
-- Rev.: 1.0
-- Creation date: NOV 2023
--
-- ---------------------------------------------------------------------
Purpose of this module:
Comments:
WARININGS
---------------------------------------------------------------------------
*/
// RDU_1_0Dlg.cpp : implementation file
//
#pragma once
#include <fstream>
#include <iostream>
#include <string>
#include <cstring>
#include <openssl/evp.h>
#include <openssl/err.h>
#include <openssl/aes.h>
#include <openssl/rand.h>
#include <sstream>
// for installation use below
// vcpkg.exe install openssl:x86-windows
/**
* @brief An instance of AESEncDec is tied to a key, with which
* files can be encrypted or decrypted as desired.
*/
class AESEncDec
{
static const int KEYLEN = 16;
static const int BLOCKSIZE = 512;
static const int ITER_COUNT = 1;
unsigned char key[KEYLEN];
unsigned char iv[BLOCKSIZE];
public:
AESEncDec(unsigned char* keybase);
int encrypt_file(const char* path,
const char* out);
int decrypt_file(const char* path,
const char* out);
//modifications made by Hamza Qureshi
//int encrypt_string(const char* path,
// const char* out);
std::string encrypt_string(const std::string& plaintext);
std::string decrypt_string(const std::string& encrypted_text);
// protected:
// void set_AES_key(unsigned char* keybase);
// const unsigned char * get_AES_key();
//
//private:
//unsigned char* key = (unsigned char*)"00000000000000000000000000000000"; // Key to be used in enc/dec
};