An invalid project ID has been used. Please go back to portfolio and select a project.
This project demonstrates object-oriented design principles by implementing classical substitution ciphers in Python. It focuses on abstraction, code reusability, and clean interface design.
This project implements three well-known encryption algorithms in Python: Caesar Cipher, Vigenère Cipher, and Affine Cipher. These ciphers were studied as part of a Computer Science course at University, and are implemented here using object-oriented programming principles, including abstract base classes.
The project is structured around an abstract base class:
class Cipher(ABC):
@abstractmethod
def encrypt(self, text: str):
pass
@abstractmethod
def decrypt(self, text: str):
pass
This ensures that every cipher has an
encrypt and decrypt function.
This is good because it makes sure any new ciphers implemented follow a consistent interface.
What is a stack? A stack is a linear data structure that operates on the principle of Last In, First Out (LIFO). This means the last element added to the stack is the first to be removed. It is similar to a stack of plates where you can only add or remove from the top.
My implementation is also thread-safe. This means if multiple threads attempt to use the same Stack instance at the same time, only one thread can modify or read critical parts of the stack at a time.
from threading import Lock
In the stack instance, there is a lock:
self._lock = Lock()
Then it gets used like this:
with self._lock:
# critical section
The with block acquires the lock before entering, runs the code inside and then automatically releases the lock.