-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.cpp
96 lines (78 loc) · 2.08 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
90
91
92
93
94
95
96
#include <iostream>
#include <cstdlib>
#include <fstream>
#include "Node.h"
#include <ctime>
#include <iomanip>
#include <sstream>
using namespace std;
int main(int argc, char* argv[]){
//instantiating nodes
Node A = Node("A", "101010");
Node B = Node("B", "101010");
Node C = Node("C", "101010");
Node D = Node("D", "101010");
Node E = Node("E", "101010");
Node F = Node("F", "101010");
//instantiating pointers to each node
Node* toA = &A;
Node* toB = &B;
Node* toC = &C;
Node* toD = &D;
Node* toE = &E;
Node* toF = &F;
//for Node A:
A.setAdjNodeOne(toB);
A.setAdjNodeTwo(toC);
A.setAdjNodeThree(toD);
A.setAdjNodeFour(toE);
A.setAdjNodeFive(toF);
//for Node B:
B.setAdjNodeOne(toA);
B.setAdjNodeTwo(toC);
B.setAdjNodeThree(toD);
B.setAdjNodeFour(toE);
B.setAdjNodeFive(toF);
//for Node C:
C.setAdjNodeOne(toA);
C.setAdjNodeTwo(toB);
C.setAdjNodeThree(toD);
C.setAdjNodeFour(toE);
C.setAdjNodeFive(toF);
//for Node D:
D.setAdjNodeOne(toA);
D.setAdjNodeTwo(toB);
D.setAdjNodeThree(toC);
D.setAdjNodeFour(toE);
D.setAdjNodeFive(toF);
//for Node E:
E.setAdjNodeOne(toA);
E.setAdjNodeTwo(toB);
E.setAdjNodeThree(toC);
E.setAdjNodeFour(toD);
E.setAdjNodeFive(toF);
//for Node F:
F.setAdjNodeOne(toA);
F.setAdjNodeTwo(toB);
F.setAdjNodeThree(toC);
F.setAdjNodeFour(toD);
F.setAdjNodeFive(toE);
A.setDataCacheOut("101101");
cout << "Before encryption: " << A.getDataCacheOut() << endl;
A.Encrypt();
cout << "After encryption: " << A.getDataCacheOutEn() << endl;
A.setDataCacheIn(A.getDataCacheOutEn());
cout << "Before decryption: " << A.getDataCacheIn() << endl;
A.Decrypt();
cout << "After decryption: " << A.getDataCacheInDe() << endl << endl << endl;
cout << "Test: A transmitting to B the message: 001010" << endl;
A.Transmit("001010", toB);
cout << "the message after B received and decrypted is: " << B.getDataCacheInDe() << endl;
time_t currT = time(0);
stringstream stream;
stream << hex << currT;
cout << "time is: " << currT << endl;
cout << asctime(localtime(&currT)) << endl;
cout << "time in hex: " << stream.str() << endl;
return 0;
}