docs: def serialize_data(data, compression=False, encryption=False, public_key=None):
      """Serializes normal Python datatypes into plaintext using json.
  
      You may also choose to enable compression and encryption when serializing
      data to send over the network. Enabling one or both of these options will
      incur additional overhead.
  
      Args:
        data (dict): The data to convert into plain text using json.
        compression (boolean): True or False value on whether or not to compress
          the serialized data.
        encryption (rsa.encryption): An encryption instance used to encrypt the
          message if encryption is desired.
        public_key (str): The public key to use to encrypt if encryption is
          enabled.
  
      Returns:
        The string message serialized using json.
  
      """
  
      message = json.dumps(data)
  
      if compression:
          message = zlib.compress(message)
          message = binascii.b2a_base64(message)
  
      if encryption and public_key:
          message = encryption.encrypt(message, public_key)
  
      encoded_message = str.encode(message)
  
      return encoded_message