-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
38 lines (32 loc) · 1.01 KB
/
main.cpp
File metadata and controls
38 lines (32 loc) · 1.01 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
#include <iostream>
#include <string>
#include "rsa.h" // RSA
#include "biginteger.h" // BigInteger
using namespace std;
void rsa_example() {
RSA rsa(17, 101);
cout << "p is " << rsa.p << endl;
cout << "q is " << rsa.q << endl;
cout << "n is " << rsa.n << endl;
cout << "e is " << rsa.e << endl;
cout << "d is " << rsa.d << endl << endl;
long unsigned int initial = 1312;
cout << "Initial message is " << initial << endl;
long unsigned int encoded = rsa.encodeMessage(initial);
cout << "Encoded message is " << encoded << endl;
long unsigned int decoded = rsa.decodeMessage(encoded);
cout << "Decoded message is " << decoded << endl;
}
void biginteger_example() {
string strNum1, strNum2;
cin >> strNum1;
cin >> strNum2;
BigInteger* integer1 = new BigInteger(strNum1);
BigInteger* integer2 = new BigInteger(strNum2);
BigInteger* res = integer1->add(integer2);
cout << res->toStringBin() << endl;
}
int main() {
biginteger_example();
return 0;
}