-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.cpp
More file actions
24 lines (18 loc) · 814 Bytes
/
example.cpp
File metadata and controls
24 lines (18 loc) · 814 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <iostream>
#include "./definition/AES.h"
using namespace std;
const unsigned int BLOCK_BYTES_LENGTH = 16 * sizeof(unsigned char);
int main() {
AES aes(128);
unsigned char plain[] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff };
unsigned char key[] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
unsigned char right[] = { 0x69, 0xc4, 0xe0, 0xd8, 0x6a, 0x7b, 0x04, 0x30, 0xd8, 0xcd, 0xb7, 0x80, 0x70, 0xb4, 0xc5, 0x5a };
unsigned int len = 0;
unsigned char *out = aes.EncryptECB(plain, 16, key, len);
unsigned char *ini = aes.DecryptECB(out, 16, key);
// printing the output
for (int i = 0; i < 16; i++) cout << ini[i] << endl;
delete[] out;
delete[] ini;
return 0;
}