diff --git a/monkey/monkey_island/cc/server_utils/encryption/key_based_encryptor.py b/monkey/monkey_island/cc/server_utils/encryption/key_based_encryptor.py index a786f2ddd..9e53e16a6 100644 --- a/monkey/monkey_island/cc/server_utils/encryption/key_based_encryptor.py +++ b/monkey/monkey_island/cc/server_utils/encryption/key_based_encryptor.py @@ -21,11 +21,10 @@ class KeyBasedEncryptor(IEncryptor): def __init__(self, key: bytes): self._key = key + self._fernet_object = Fernet(self._key) def encrypt(self, plaintext: bytes) -> bytes: - fernet_object = Fernet(self._key) - return fernet_object.encrypt(plaintext.encode()) + return self._fernet_object.encrypt(plaintext.encode()) def decrypt(self, ciphertext: bytes) -> bytes: - fernet_object = Fernet(self._key) - return fernet_object.decrypt(ciphertext) + return self._fernet_object.decrypt(ciphertext)