Island: Create custom type EncryptionKey32Bit

This commit is contained in:
Shreya Malviya 2022-07-19 17:09:49 +05:30
parent cbe842029a
commit d55e7b1455
1 changed files with 16 additions and 0 deletions

View File

@ -15,6 +15,22 @@ logger = logging.getLogger(__name__)
# Note: password != key
class SizeError(Exception):
"""
Raised when an argument is not of the expected size during object creation.
"""
pass
class EncryptionKey32Bit(bytes):
def __init__(self, key: bytes):
if len(key) == 32:
self.key = key
else:
raise SizeError("Key size should be 32 bytes.")
class KeyBasedEncryptor(IEncryptor):
def __init__(self, key: bytes):
"""