def encrypt(self, message, public_key):
<EOL>max_str_len = rsa.common.byte_size(public_key.n) - <NUM_LIT:11><EOL>if len(message) > max_str_len:<EOL><INDENT>message = textwrap.wrap(message, width=max_str_len)<EOL><DEDENT>else:<EOL><INDENT>message = [message]<EOL><DEDENT>enc_msg = []<EOL>for line in message:<EOL><INDENT>enc_line = rsa.encrypt(line, public_key)<EOL>enc_line_converted = binascii.b2a_base64(enc_line)<EOL>enc_msg.append(enc_line_converted)<EOL><DEDENT>enc_msg = json.dumps(enc_msg)<EOL>return enc_msg<EOL>
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.