-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathmain.cpp
55 lines (43 loc) · 1.4 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
#include <iostream>
#include <exception>
#include "src/RSA.h"
#include "src/Decryptor.h"
#include "src/Encryptor.h"
using std::string;
int main()
{
try
{
Crypto::RSA rsa(11, 17, 3);
// String message to encrypt
string in_str;
std::cout << "[INF] Please enter a string message...\n";
std::getline(std::cin, in_str);
Crypto::CryptoString out_str = rsa.encrypt(in_str); // Encrypt message
string res_str = rsa.decrypt(out_str); // Decrypt message
std::cout << "[INF] Result of RSA:\n";
std::cout << "Input Message: " << in_str << "\n"
//<< "Encrypted message: " << out_str << "\n"
<< "Decrypted message: " << res_str << "\n";
// ------------------------------------------------------------------------
// Character to encrypt
char in_ch;
std::cout << "[INF] Please enter one character...\n";
std::cin >> in_ch;
Crypto::CryptoChar out_ch = rsa.encrypt(in_ch);
char res_ch = rsa.decrypt(out_ch);
std::cout << "[INF] Result of RSA:\n";
std::cout << "Input Message: " << in_ch << "\n"
//<< "Encrypted message: " << out_str << "\n"
<< "Decrypted message: " << res_ch << "\n";
// -------------------------
std::string tmp;
std::getline(std::cin, tmp);
}
catch (std::exception &e)
{
std::cout << "[ERR] RSA-exception thrown!\n";
std::cout << e.what();
}
return 0;
}