https://github.com/seigtm/strategyfileencrypter
An example of text files encryption using the strategy design pattern.
https://github.com/seigtm/strategyfileencrypter
cipher cipher-algorithms encrypt encryption encryption-algorithms encryption-decryption encryption-strategies file-encrypter file-encryption files-encrypter files-encryption hierarchy strategy strategy-design-pattern strategy-pattern text-cryptography text-encryption
Last synced: 10 days ago
JSON representation
An example of text files encryption using the strategy design pattern.
- Host: GitHub
- URL: https://github.com/seigtm/strategyfileencrypter
- Owner: seigtm
- Created: 2021-04-17T20:44:34.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2021-06-17T18:47:38.000Z (almost 4 years ago)
- Last Synced: 2023-03-08T19:16:12.345Z (about 2 years ago)
- Topics: cipher, cipher-algorithms, encrypt, encryption, encryption-algorithms, encryption-decryption, encryption-strategies, file-encrypter, file-encryption, files-encrypter, files-encryption, hierarchy, strategy, strategy-design-pattern, strategy-pattern, text-cryptography, text-encryption
- Language: C++
- Homepage:
- Size: 8.79 KB
- Stars: 5
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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 ...
```