Encrypts a string using a given rsa.PublicKey object. If the message
        is larger than the key, it will split it up into a list and encrypt
        each line in the list.

        Args:
          message (string): The string to encrypt.
          public_key (rsa.PublicKey): The key object used to encrypt the
            message. Only the paired private key can decrypt it.

        Returns:
        A json string of the list of encrypted lines of the message.

def encrypt(self, message, public_key):
        """Encrypts a string using a given rsa.PublicKey object. If the message
        is larger than the key, it will split it up into a list and encrypt
        each line in the list.

        Args:
          message (string): The string to encrypt.
          public_key (rsa.PublicKey): The key object used to encrypt the
            message. Only the paired private key can decrypt it.

        Returns:
        A json string of the list of encrypted lines of the message.

        """
        # Get the maximum message length based on the key
        max_str_len = rsa.common.byte_size(public_key.n) - 11

        # If the message is longer than the key size, split it into a list to
        # be encrypted
        if len(message) > max_str_len:
            message = textwrap.wrap(message, width=max_str_len)
        else:
            message = [message]

        # Create a list for the encrypted message to send
        enc_msg = []

        # If we have a long message, loop through and encrypt each part of the
        # string
        for line in message:

            # Encrypt the line in the message into a bytestring
            enc_line = rsa.encrypt(line, public_key)

            # Convert the encrypted bytestring into ASCII, so we can send it
            # over the network
            enc_line_converted = binascii.b2a_base64(enc_line)

            enc_msg.append(enc_line_converted)

        # Serialize the encrypted message again with json
        enc_msg = json.dumps(enc_msg)

        # Return the list of encrypted strings
        return enc_msg