code: def encrypt(self, passphrase, sessionkey=None, **prefs):
          
          cipher_algo = prefs.pop('cipher', SymmetricKeyAlgorithm.AES256)
          hash_algo = prefs.pop('hash', HashAlgorithm.SHA256)
  
          # set up a new SKESessionKeyV4
          skesk = SKESessionKeyV4()
          skesk.s2k.usage = 255
          skesk.s2k.specifier = 3
          skesk.s2k.halg = hash_algo
          skesk.s2k.encalg = cipher_algo
          skesk.s2k.count = skesk.s2k.halg.tuned_count
  
          if sessionkey is None:
              sessionkey = cipher_algo.gen_key()
          skesk.encrypt_sk(passphrase, sessionkey)
          del passphrase
  
          msg = PGPMessage() | skesk
  
          if not self.is_encrypted:
              skedata = IntegrityProtectedSKEDataV1()
              skedata.encrypt(sessionkey, cipher_algo, self.__bytes__())
              msg |= skedata
  
          else:
              msg |= self
  
          return msg
docs: Encrypt the contents of this message using a passphrase.
          :param passphrase: The passphrase to use for encrypting this message.
          :type passphrase: ``str``, ``unicode``, ``bytes``
  
          :optional param sessionkey: Provide a session key to use when encrypting something. Default is ``None``.
                                      If ``None``, a session key of the appropriate length will be generated randomly.
  
                                      .. warning::
  
                                          Care should be taken when making use of this option! Session keys *absolutely need*
                                          to be unpredictable! Use the ``gen_key()`` method on the desired
                                          :py:obj:`~constants.SymmetricKeyAlgorithm` to generate the session key!
  
          :type sessionkey: ``bytes``, ``str``
          :raises: :py:exc:`~errors.PGPEncryptionError`
          :returns: A new :py:obj:`PGPMessage` containing the encrypted contents of this message.