def encrypt_assertion(self, statement, enc_key, template, key_type='des-192', node_xpath=None, node_id=None):
        """
        Will encrypt an assertion

        :param statement: A XML document that contains the assertion to encrypt
        :param enc_key: File name of a file containing the encryption key
        :param template: A template for the encryption part to be added.
        :param key_type: The type of session key to use.
        :return: The encrypted text
        """
        if six.PY2:
            _str = unicode
        else:
            _str = str

        if isinstance(statement, SamlBase):
            statement = pre_encrypt_assertion(statement)

        _, fil = make_temp(
            _str(statement), decode=False, delete=self._xmlsec_delete_tmpfiles
        )
        _, tmpl = make_temp(_str(template), decode=False)

        if not node_xpath:
            node_xpath = ASSERT_XPATH

        com_list = [
            self.xmlsec,
            '--encrypt',
            '--pubkey-cert-pem', enc_key,
            '--session-key', key_type,
            '--xml-data', fil,
            '--node-xpath', node_xpath,
        ]

        if node_id:
            com_list.extend(['--node-id', node_id])

        try:
            (_stdout, _stderr, output) = self._run_xmlsec(com_list, [tmpl])
        except XmlsecError as e:
            six.raise_from(EncryptError(com_list), e)

        return output.decode('utf-8')