Skip to content

Commit 27e19a6

Browse files
committed
Update README
1 parent accf1e3 commit 27e19a6

File tree

4 files changed

+74
-3
lines changed

4 files changed

+74
-3
lines changed

README.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,71 @@ Containing algorithms are the *basic euclidean algorithm* to calculate the *grea
3131
Contains *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
36101
MIT License

RSA.vcxproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,9 @@
224224
<ClInclude Include="src\math\Euclidean.h" />
225225
<ClInclude Include="src\RSA.h" />
226226
</ItemGroup>
227+
<ItemGroup>
228+
<None Include="README.md" />
229+
</ItemGroup>
227230
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
228231
<ImportGroup Label="ExtensionTargets">
229232
</ImportGroup>

RSA.vcxproj.filters

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,7 @@
5959
<Filter>Headerdateien</Filter>
6060
</ClInclude>
6161
</ItemGroup>
62+
<ItemGroup>
63+
<None Include="README.md" />
64+
</ItemGroup>
6265
</Project>

src/RSA.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ namespace Crypto
124124
//
125125
// str: string to decrypt
126126
//
127-
// return: string; Encrypted message
127+
// return: string; Decrypted message
128128
//
129129
string decrypt(CryptoString str);
130130

@@ -134,15 +134,15 @@ namespace Crypto
134134
// ch: character to be encrypted
135135
//
136136
// return: CryptoChar; Boost's 256bit integer which contains
137-
// encrypted character
137+
// the encrypted character
138138
//
139139
CryptoChar encrypt(char ch);
140140

141141
//-----------------------------------------------------
142142
// Decrypts a string
143143
//
144144
// str: character to decrypt; Boost's 256bit integer which contains
145-
// encrypted character
145+
// the decrypted character
146146
//
147147
// return: char; Encrypted character
148148
//

0 commit comments

Comments
 (0)