encryptlib package#
Submodules#
encryptlib.core module#
ENcrypt: A Encryption Library
This module implements a custom encryption algorithm based on matrix operations and periodic decimal expansions. It’s designed for educational purposes as part of the TUBITAK 2204-a project.
The encryption process uses a key derived from numbers ending in 9 to generate a 2x2 matrix for encryption/decryption operations.
Example
>>> encryptor = ENcrypt(59)
>>> encrypted = encryptor.encrypt("Hello World")
>>> decrypted = encryptor.decrypt(encrypted)
>>> assert "hello world" == decrypted.lower()
- class encryptlib.core.ENcrypt(value, alphabet=None)[source]#
Bases:
objectA class implementing matrix-based encryption and decryption operations.
- approx#
High-precision approximation of 1/value.
- Type:
mpf
- exception encryptlib.core.EncryptionError[source]#
Bases:
ExceptionBase exception class for encryption-related errors.
- exception encryptlib.core.InvalidKeyError[source]#
Bases:
EncryptionErrorRaised when the encryption key is invalid.
- exception encryptlib.core.MessageFormatError[source]#
Bases:
EncryptionErrorRaised when the message format is invalid.
encryptlib.exceptions module#
Exception classes for the encryptlib package.
- exception encryptlib.exceptions.EncryptionError[source]#
Bases:
ExceptionBase exception class for encryption-related errors.
- exception encryptlib.exceptions.InvalidKeyError[source]#
Bases:
EncryptionErrorRaised when the encryption key is invalid.
- exception encryptlib.exceptions.MessageFormatError[source]#
Bases:
EncryptionErrorRaised when the message format is invalid.
encryptlib.utils module#
Utility functions for the encryptlib package.
- encryptlib.utils.matrix_to_numbers(matrix, alphabet)[source]#
Convert a matrix of characters to a matrix of numbers based on the alphabet.
- Parameters:
- Return type:
- Returns:
A matrix of corresponding numeric values.
- Raises:
ValueError – If a character is not found in the alphabet.
- encryptlib.utils.validate_alphabet(alphabet)[source]#
Validate the provided alphabet.
- Parameters:
alphabet (
str) – The alphabet to validate.- Raises:
ValueError – If the alphabet contains duplicate characters.
- Return type:
Module contents#
ENcrypt: A Matrix-based Encryption Library
A secure and efficient encryption library using matrix operations and periodic decimal expansions, developed as part of the TUBITAK 2204-a project.
- class encryptlib.ENcrypt(value, alphabet=None)[source]#
Bases:
objectA class implementing matrix-based encryption and decryption operations.
- approx#
High-precision approximation of 1/value.
- Type:
mpf
- exception encryptlib.EncryptionError[source]#
Bases:
ExceptionBase exception class for encryption-related errors.
- exception encryptlib.InvalidKeyError[source]#
Bases:
EncryptionErrorRaised when the encryption key is invalid.
- exception encryptlib.MessageFormatError[source]#
Bases:
EncryptionErrorRaised when the message format is invalid.