Encryptor
Abstract base class for encryption interfaces.
This module defines the BaseEncryptor which serves as the abstract base class for all encryption implementations in the system.
References
NONE
BaseEncryptor
Bases: ABC
Abstract base class defining the interface for encryption implementations.
This abstract base class ensures that all encryptors implement the required encrypt and decrypt methods with consistent signatures.
Thread-safety requirement
Implementations MUST be thread-safe. The client may
invoke encrypt and decrypt concurrently from multiple threads, so
any internal state (e.g., buffers, nonces, cipher instances) must be
protected or designed to avoid race conditions.
decrypt(ciphertext)
abstractmethod
Decrypt cipher text back into plain text.
This method should be implemented by subclasses to provide the decryption functionality.
Note
The implementation must be thread-safe and must not mutate shared state without proper synchronization.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ciphertext |
str
|
The ciphertext to decrypt. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The decrypted plain text. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If the method is not implemented by the subclass. |
encrypt(plaintext)
abstractmethod
Encrypt plain text into cipher text.
This method should be implemented by subclasses to provide the encryption functionality.
Note
The implementation must be thread-safe and must not mutate shared state without proper synchronization.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
plaintext |
str
|
The raw plain text to encrypt. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The encrypted cipher text. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If the method is not implemented by the subclass. |