-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
89 lines (77 loc) · 2.8 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
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
83
84
85
86
87
88
89
#include "RIPEMD-160.h"
#include "Exp.h"
using namespace std;
int main(int argc, char** argv)
{
RIPEMD_160 hash;
if (!hash.read_file("in.txt")) cout << "Îøèáêà ÷òåíèÿ ôàéëà!" << endl << endl;
else if (!hash.write_file((char*)"out.txt", hash.ripemd_160()))
cout << "Îøèáêà çàïèñè ôàéëà!" << endl << endl;
ofstream out_preimage("preim.txt");
ofstream out_collis("collis.txt");
out_preimage << "0 0" << endl;
out_collis << "0 0" << endl;
unsigned seed = time(0);
srand(seed);
//ïðîâåñòè ýêñïåðèìåíò
Exp e1;
e1.n = 2;
out_preimage << "8 ";
out_collis << "8 ";
///íàõîæäåíèå ñðåäíåãî
for (int i = 0; i < 1000; i++) {
e1.exp_finish();
}
e1.S_dif[0] = e1.average(e1.s_dif);
e1.S_col[0] = e1.average(e1.s_col);
e1.s_dif.clear();
e1.s_col.clear();
cout << "1)complexity of the second preimage: " << e1.S_dif[0] << endl;
cout << "1)complexity of collision: " << e1.S_col[0] << endl;
out_preimage << e1.S_dif[0] << endl;
out_collis << e1.S_col[0] << endl;
e1.n = 3;
out_preimage << "12 ";
out_collis << "12 ";
///íàõîæäåíèå ñðåäíåãî
for (int i = 0; i < 1000; i++) {
e1.exp_finish();
}
e1.S_dif[1] = e1.average(e1.s_dif);
e1.S_col[1] = e1.average(e1.s_col);
e1.s_dif.clear();
e1.s_col.clear();
cout << "2)complexity of the second preimage: " << e1.S_dif[1] << endl;
cout << "2)complexity of collision: " << e1.S_col[1] << endl;
out_preimage << e1.S_dif[1] << endl;
out_collis << e1.S_col[1] << endl;
e1.n = 4;
out_preimage << "16 ";
out_collis << "16 ";
///íàõîæäåíèå ñðåäíåãî
for (int i = 0; i < 1000; i++) {
e1.exp_finish();
}
e1.S_dif[2] = e1.average(e1.s_dif);
e1.S_col[2] = e1.average(e1.s_col);
e1.s_dif.clear();
e1.s_col.clear();
cout << "3)complexity of the second preimage: " << e1.S_dif[2] << endl;
cout << "3)complexity of collision: " << e1.S_col[2] << endl;
out_preimage << e1.S_dif[2] << endl;
out_collis << e1.S_col[2] << endl;
e1.n = 5;
///íàõîæäåíèå ñðåäíåãî
for (int i = 0; i < 500; i++) {
e1.exp_finish();
}
e1.S_dif[3] = e1.average(e1.s_dif);
e1.S_col[3] = e1.average(e1.s_col);
e1.s_dif.clear();
e1.s_col.clear();
cout << "4)complexity of the second preimage: " << e1.S_dif[3] << endl;
cout << "4)complexity of collision: " << e1.S_col[3] << endl;
out_preimage << e1.S_dif[3] << endl;
out_collis << e1.S_col[3] << endl;
return 0;
}