(self, data, **kwargs)
return result
Create a signature for a message string or file.

        Note that this method is not for signing other keys. (In GnuPG's
        terms, what we all usually call 'keysigning' is actually termed
        'certification'...) Even though they are cryptographically the same
        operation, GnuPG differentiates between them, presumedly because these
        operations are also the same as the decryption operation. If the
        ``key_usage``s ``C (certification)``, ``S (sign)``, and ``E
        (encrypt)``, were all the same key, the key would "wear down" through
        frequent signing usage -- since signing data is usually done often --
        meaning that the secret portion of the keypair, also used for
        decryption in this scenario, would have a statistically higher
        probability of an adversary obtaining an oracle for it (or for a
        portion of the rounds in the cipher algorithm, depending on the family
        of cryptanalytic attack used).

        In simpler terms: this function isn't for signing your friends' keys,
        it's for something like signing an email.

        :type data: :obj:`str` or :obj:`file`
        :param data: A string or file stream to sign.
        :param str default_key: The key to sign with.
        :param str passphrase: The passphrase to pipe to stdin.
        :param bool clearsign: If True, create a cleartext signature.
        :param bool detach: If True, create a detached signature.
        :param bool binary: If True, do not ascii armour the output.
        :param str digest_algo: The hash digest to use. Again, to see which
            hashes your GnuPG is capable of using, do:
            :command:`$ gpg --with-colons --list-config digestname`.
            The default, if unspecified, is ``'SHA512'``.
Create a signature for a message string or file.
Create a signature for a message string or file .
def sign(self, data, **kwargs):
        """Create a signature for a message string or file.

        Note that this method is not for signing other keys. (In GnuPG's
        terms, what we all usually call 'keysigning' is actually termed
        'certification'...) Even though they are cryptographically the same
        operation, GnuPG differentiates between them, presumedly because these
        operations are also the same as the decryption operation. If the
        ``key_usage``s ``C (certification)``, ``S (sign)``, and ``E
        (encrypt)``, were all the same key, the key would "wear down" through
        frequent signing usage -- since signing data is usually done often --
        meaning that the secret portion of the keypair, also used for
        decryption in this scenario, would have a statistically higher
        probability of an adversary obtaining an oracle for it (or for a
        portion of the rounds in the cipher algorithm, depending on the family
        of cryptanalytic attack used).

        In simpler terms: this function isn't for signing your friends' keys,
        it's for something like signing an email.

        :type data: :obj:`str` or :obj:`file`
        :param data: A string or file stream to sign.
        :param str default_key: The key to sign with.
        :param str passphrase: The passphrase to pipe to stdin.
        :param bool clearsign: If True, create a cleartext signature.
        :param bool detach: If True, create a detached signature.
        :param bool binary: If True, do not ascii armour the output.
        :param str digest_algo: The hash digest to use. Again, to see which
            hashes your GnuPG is capable of using, do:
            :command:`$ gpg --with-colons --list-config digestname`.
            The default, if unspecified, is ``'SHA512'``.
        """
        if 'default_key' in kwargs:
            log.info("Signing message '%r' with keyid: %s"
                     % (data, kwargs['default_key']))
        else:
            log.warn("No 'default_key' given! Using first key on secring.")

        if hasattr(data, 'read'):
            result = self._sign_file(data, **kwargs)
        elif not _is_stream(data):
            stream = _make_binary_stream(data, self._encoding)
            result = self._sign_file(stream, **kwargs)
            stream.close()
        else:
            log.warn("Unable to sign message '%s' with type %s"
                     % (data, type(data)))
            result = None
        return result
def sign ( self , data , * * kwargs ) : if 'default_key' in kwargs : log . info ( "Signing message '%r' with keyid: %s" % ( data , kwargs [ 'default_key' ] ) ) else : log . warn ( "No 'default_key' given! Using first key on secring." ) if hasattr ( data , 'read' ) : result = self . _sign_file ( data , * * kwargs ) elif not _is_stream ( data ) : stream = _make_binary_stream ( data , self . _encoding ) result = self . _sign_file ( stream , * * kwargs ) stream . close ( ) else : log . warn ( "Unable to sign message '%s' with type %s" % ( data , type ( data ) ) ) result = None return result