Skip to content

Commit 3383674

Browse files
committed
Added nice cmd input
1 parent 5837108 commit 3383674

File tree

1 file changed

+21
-16
lines changed

1 file changed

+21
-16
lines changed

main.cpp

+21-16
Original file line numberDiff line numberDiff line change
@@ -8,37 +8,42 @@ using std::string;
88

99
int main()
1010
{
11-
//Crypto::RSA rsa(6907, 7687, 491);
12-
1311
try
1412
{
15-
Crypto::RSA rsa(6907, 7687, 24);
16-
17-
//-----------
18-
// String message
19-
//
13+
Crypto::RSA rsa(11, 17, 3);
2014

21-
string in_str = "This is a bretty long message, with extra special caharacters and no deeber meaning!";
15+
// String message to encrypt
16+
string in_str;
17+
std::cout << "[INF] Please enter a string message...\n";
18+
std::getline(std::cin, in_str);
2219

23-
Crypto::CryptoString out_str = rsa.encrypt(in_str);
24-
string res_str = rsa.decrypt(out_str);
20+
Crypto::CryptoString out_str = rsa.encrypt(in_str); // Encrypt message
21+
string res_str = rsa.decrypt(out_str); // Decrypt message
2522

26-
std::cout << "input: " << in_str << " | output: " << res_str << "\n";
23+
std::cout << "[INF] Result of RSA:\n";
24+
std::cout << "Input Message: " << in_str << "\n"
25+
//<< "Encrypted message: " << out_str << "\n"
26+
<< "Decrypted message: " << res_str << "\n";
2727

28-
//-----------
29-
// Character message
30-
//
28+
// ------------------------------------------------------------------------
3129

32-
char in_ch = 'X';
30+
// Character message to encrypt
31+
char in_ch;
32+
std::cout << "[INF] Please enter one character...\n";
33+
std::cin >> in_ch;
3334

3435
Crypto::CryptoChar out_ch = rsa.encrypt(in_ch);
3536
char res_ch = rsa.decrypt(out_ch);
3637

37-
std::cout << "input: " << in_ch << " | output: " << res_ch << "\n";
38+
std::cout << "[INF] Result of RSA:\n";
39+
std::cout << "Input Message: " << in_ch << "\n"
40+
//<< "Encrypted message: " << out_str << "\n"
41+
<< "Decrypted message: " << res_ch << "\n";
3842

3943
}
4044
catch (std::exception &e)
4145
{
46+
std::cout << "[ERR] RSA-exception thrown!\n";
4247
std::cout << e.what();
4348
}
4449

0 commit comments

Comments
 (0)