-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest-context.cpp
More file actions
72 lines (61 loc) · 2.08 KB
/
test-context.cpp
File metadata and controls
72 lines (61 loc) · 2.08 KB
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
#include <cmath>
#include <iostream>
#include "Context.h"
void testContext(Context context){
cout << "-------------------------------------------------------------------" << endl;
cout << "taille = 5"<<endl;
cout << "alphabet = abcdefghijklmnopqrstuvwxyz" << endl;
cout << "nblettres= 26"<< endl;
cout << "N = 11881376" << endl;
cout << "T = 50000" << endl;
cout << "M = 100" << endl;
cout << endl;
cout << "-------- Exemples de calcul des fonctions i2c, h, c2i(t) ----------" << endl;
uint64 idxStart[10] = {11844934, 11444147, 6723391, 4442476, 5431405, 2374699, 6220699, 5604454, 11769570, 9018072};
string clear;
byte hashed[16];
uint64 idxEnd;
for(int i=0; i<10; i++){
context.i2c(idxStart[i],clear);
context.h(clear,hashed);
idxEnd = context.h2i(1,hashed);
cout << idxStart[i] << " -i2c-> " << clear << " -h-> " << md5ToString(hashed) << " -h2i(1)->"<< idxEnd << endl;
cout << idxStart[i] << " -i2i(1)-> " << context.i2i(idxStart[i], 1) << endl;
}
}
bool testChainCalcul(Context context){
cout << "-------- Exemples de calcul de chaînes de longueur T=50000 ----------" << endl;
uint64 idxStart[11] = {1172136, 427373, 1144282, 6286051, 6839583, 7356570, 5866002, 2529175, 3285784, 3354650,442565};
uint64 idxEnd;
for(int i=0; i<11; i++){
idxEnd = idxStart[i];
cout << idxStart[i] << " -i2i(1)-> ... ";
for(unsigned j=1; j< 50000; j++){
idxEnd = context.i2i(idxEnd,j);
}
cout << "-i2i(49999)-> " << idxEnd << endl;
}
return true;
}
bool testh2i(Context context){
bool result = true;
//Test i2c
string c = "";
context.i2c(11844934,c);
cout << "i2c = " << c <<endl;
return result;
}
bool testi2i(Context context){
bool result = true;
//Test i2c
string c = "";
context.i2c(11844934,c);
cout << "i2c = " << c <<endl;
return result;
}
int main(int argc, char** argv){
Context context(5,5,"abcdefghijklmnopqrstuvwxyz");
testContext(context);
testChainCalcul(context);
return 0;
}