-
Notifications
You must be signed in to change notification settings - Fork 2
/
test.cpp
65 lines (52 loc) · 1.52 KB
/
test.cpp
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
#include <iostream>
#include <iomanip>
#include "aes256.h"
#include <vector>
#include <array>
void printMemo(std::vector<uint8_t> s){
for(int i=0; i<s.size(); i++){
if(i%16==0) std::cout << " ";
std::cout << std::setfill('0') << std::setw(2) << std::hex << static_cast<int>(s[i]);
}
std::cout<<"\n";
}
int main(){
AES256 aes;
std::vector<uint8_t> key(32);
for(int i=0; i<32; i++){
key[i] = i;
}
// std::vector<uint8_t> input(32);
// std::array<uint8_t, 40> input;
uint8_t* input = new uint8_t[40];
for(int i=0; i<16; i++){
input[i] = i*17;
std::cout << std::setfill('0') << std::setw(2) << std::hex << static_cast<int>(input[i]);
}
for(int i=0; i<16; i++){
input[i+16] = input[i];
if((i+16)%16==0) std::cout << " ";
std::cout << std::setfill('0') << std::setw(2) << std::hex << static_cast<int>(input[i+16]);
}
for(int i=0; i<8; i++){
input[i+32] = input[i];
if((i+32)%16==0) std::cout << " ";
std::cout << std::setfill('0') << std::setw(2) << std::hex << static_cast<int>(input[i+32]);
}
// for(int i=0; i<8; i++){
// input[i+40] = 0;
// if((i+40)%16==0) std::cout << " ";
// std::cout << std::setfill('0') << std::setw(2) << std::hex << static_cast<int>(input[i+40]);
// }
std::cout << "\n";
printMemo(key);
// printMemo(input);
std::vector<uint8_t> encryptedData;
encryptedData = aes.encrypt(input, 40, key);
printMemo(encryptedData);
std::vector<uint8_t> decryptedData;
decryptedData = aes.decrypt(encryptedData, 40, key);
printMemo(decryptedData);
delete[] input;
return 0;
}