-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
51 lines (33 loc) · 1.09 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
#include <iostream>
#include <cstdio>
#include <chrono>
#include <assert.h>
#include "RSA.h"
//#include "GUI.h"
using namespace std;
int main(int argc, char** argv) {
std::chrono::time_point<std::chrono::system_clock> start, end;
string message;
string text = "----------"; //510 characters for 2048 bit 1020 characters for 4096
for(int i = 0; i<102; i++){
message.append(text);
}
RSA rsa;
bool privKey = rsa.loadPrivateKey("");
bool pubKey = rsa.loadPublicKey("");
if(!privKey || !pubKey) {
rsa.generateKeys(4096);
rsa.saveKeys("");
}
string encryptedMessage = rsa.encryptMessage(message);
start = std::chrono::system_clock::now();
string decryptedMessage = rsa.decryptMessage(encryptedMessage);
end = std::chrono::system_clock::now();
cout << "encrypted: " << endl;
cout << encryptedMessage << endl;
cout << "decrypted:" << endl;
cout << decryptedMessage << endl;
std::chrono::duration<double> elapsed_seconds = end-start;
cout << "time: " << elapsed_seconds.count() << "s\n";
return 0;
}