-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
47 lines (43 loc) · 1.1 KB
/
main.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
#include <iostream>
#include "AES.h"
using namespace std;
int main() {
byte plain[16] = {0x32, 0x88, 0x31, 0xe0,
0x43, 0x5a, 0x31, 0x37,
0xf6, 0x30, 0x98, 0x07,
0xa8, 0x8d, 0xa2, 0x34};
AES test;
//test.setKey();
cout << "Key is:";
for (int i = 0; i < 16; ++i) {
cout << hex << test.getKet()[i].to_ulong() << " ";
}
cout << endl;
cout<<endl<<"待加密的明文:"<<endl;
for(int i=0;i<16;++i)
{
cout<<hex<<plain[i].to_ulong()<<" ";
if((i+1)%4==0)
cout<<endl;
}
cout<<endl;
test.encrypt(plain);
cout<<"加密后的密文:"<<endl;
for (int i = 0; i < 16; ++i) {
cout << hex << plain[i].to_ulong() << " ";
if((i+1)%4 == 0)
cout << endl;
}
cout << endl;
// 解密,输出明文
test.decrypt(plain);
cout << "解密后的明文:"<<endl;
for(int i=0; i<16; ++i)
{
cout << hex << plain[i].to_ulong() << " ";
if((i+1)%4 == 0)
cout << endl;
}
cout << endl;
return 0;
}