From bd1c788a4c8312cdb4e67a4a36539dbd78438fa3 Mon Sep 17 00:00:00 2001 From: Shreya Malviya Date: Tue, 19 Jul 2022 15:04:20 +0530 Subject: [PATCH] Island: Add docstrings to KeyBasedEncryptor --- .../encryption/key_based_encryptor.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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 772466a28..a5cc1a6a7 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 @@ -17,11 +17,27 @@ logger = logging.getLogger(__name__) class KeyBasedEncryptor(IEncryptor): def __init__(self, key: bytes): + """ + Initializes a KeyBasedEncryptor object + :param bytes key: The encryption key with which the object should be initialized + """ self._key = key self._fernet_object = Fernet(self._key) def encrypt(self, plaintext: bytes) -> bytes: + """ + Encrypts a given bytestream + :param bytes plaintext: The bytestream to encrypt + :return: Encrypted message + :rtype: bytes + """ return self._fernet_object.encrypt(plaintext) def decrypt(self, ciphertext: bytes) -> bytes: + """ + Decrypts a given bytestream + :param bytes ciphertext: The bytestream to decrypt + :return: Decrypted message + :rtype: bytes + """ return self._fernet_object.decrypt(ciphertext)