This repository has been archived by the owner on Feb 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
README.md and Comments in source code
- Loading branch information
Showing
2 changed files
with
117 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Text files encryption using strategy design pattern in C++. | ||
|
||
This source code is a template of using the **strategy** design pattern for text files encryption in C++. | ||
This project is a homework from my college programming teacher. | ||
|
||
## Problem statement: | ||
|
||
> Develop the program for encrypting text documents. | ||
> The user enters a string containing the path to the text file ("C:/example.txt"). | ||
> After that, he enters a number from 1 to 3 to clarify the text encryption method. | ||
> After the selected algorithm works, the encrypted text is saved to another file ("C:/example_ciphered.txt"). | ||
> Develop the console application that implements the described functionality and contains a hierarchy of encryption classes. | ||
> Justify the selected class hierarchy and the selected design pattern. | ||
## Implementation: | ||
|
||
A basic virtual class for std::string encryption strategies: | ||
|
||
```cpp | ||
class EncryptionStrategy | ||
{ | ||
public: | ||
virtual std::string encrypt(const std::string &text, const std::string &key = "") = 0; | ||
virtual std::string decrypt(const std::string &text, const std::string &key = "") = 0; | ||
}; | ||
``` | ||
|
||
Concrete encryption strategy using XOR: | ||
|
||
```cpp | ||
class XOREncryptionStrategy : public EncryptionStrategy ... | ||
``` | ||
Concrete encryption strategy using Caesar: | ||
```cpp | ||
class CaesarEncryptionStrategy : public EncryptionStrategy ... | ||
``` | ||
|
||
Concrete encryption strategy using Binary code: | ||
|
||
```cpp | ||
class BinaryEncryptionStrategy : public EncryptionStrategy ... | ||
``` | ||
Interface for file encryption using encryption strategies: | ||
```cpp | ||
class IFileEncryptor ... | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters