@@ -31,6 +31,71 @@ Containing algorithms are the *basic euclidean algorithm* to calculate the *grea
3131Contains * unit tests* .
3232
3333## Usage
34+ First of all an instance of RSA has to be created.
35+ RSA has two main functions * encrypt()* and * decrypt()* . Each two times, one for en-/decrypt strings and one for en-/decrypt characters.
36+ The method signatures are the following:
37+ ```
38+ //-----------------------------------------------------
39+ // Encrypts a string
40+ //
41+ // str: string to be encrypted
42+ //
43+ // return: CryptoString; Structure which contains
44+ // encrypted message
45+ //
46+ CryptoString encrypt(string str);
47+
48+ //-----------------------------------------------------
49+ // Decrypts a string
50+ //
51+ // str: string to decrypt
52+ //
53+ // return: string; Decrypted message
54+ //
55+ string decrypt(CryptoString str);
56+
57+ //-----------------------------------------------------
58+ // Encrypts a string
59+ //
60+ // ch: character to be encrypted
61+ //
62+ // return: CryptoChar; Boost's 256bit integer which contains
63+ // the encrypted character
64+ //
65+ CryptoChar encrypt(char ch);
66+
67+ //-----------------------------------------------------
68+ // Decrypts a string
69+ //
70+ // str: character to decrypt; Boost's 256bit integer which contains
71+ // the decrypted character
72+ //
73+ // return: char; Encrypted character
74+ //
75+ char decrypt(CryptoChar str);
76+ ```
77+ All together an example for an en-/decryption of a string:
78+ ```
79+ try
80+ {
81+ Crypto::RSA rsa(6907, 7687, 24);
82+
83+ // Message to encrypt
84+ string in_str = "This is a bretty long message, with extra special caharacters and no deeber meaning!";
85+
86+ // Encrypt message
87+ Crypto::CryptoString out_str = rsa.encrypt(in_str);
88+ // Decrypt message
89+ string res_str = rsa.decrypt(out_str);
90+
91+ // Print to console
92+ std::cout << "input: " << in_str << " | output: " << res_str << "\n";
93+ }
94+ catch (std::exception &e)
95+ {
96+ std::cout << e.what();
97+ }
98+ ```
3499
35100## License
36101MIT License
0 commit comments