当前位置: 首页>>代码示例>>Python>>正文


Python GPG.sign_file方法代码示例

本文整理汇总了Python中gnupg.GPG.sign_file方法的典型用法代码示例。如果您正苦于以下问题:Python GPG.sign_file方法的具体用法?Python GPG.sign_file怎么用?Python GPG.sign_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gnupg.GPG的用法示例。


在下文中一共展示了GPG.sign_file方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: sign

# 需要导入模块: from gnupg import GPG [as 别名]
# 或者: from gnupg.GPG import sign_file [as 别名]
    def sign(self, dist):
        self._reprepro('export %s' % dist)

        gpg = GPG()
        filename = os.path.join(self.path, 'dists/%s/Release' % dist)
        detach_file = filename + '.gpg'
        try:
            os.unlink(detach_file)
        except: pass
        result = gpg.sign_file(file(filename, 'r'), keyid=conf('repository.signkey'), outputfile=detach_file)
开发者ID:simplegeo,项目名称:repoman,代码行数:12,代码来源:repository.py

示例2: sign

# 需要导入模块: from gnupg import GPG [as 别名]
# 或者: from gnupg.GPG import sign_file [as 别名]
def sign(config, s_filename):
    """sign the package"""
    gpg_home = config.get('gpg_dir', '/var/lib/sachannelupdate/gnupg')
    gpg_pass = config.get('gpg_passphrase')
    gpg_keyid = config.get('gpg_keyid')
    gpg = GPG(gnupghome=gpg_home)
    try:
        plaintext = open(s_filename, 'rb')
        signature = gpg.sign_file(
            plaintext, keyid=gpg_keyid, passphrase=gpg_pass, detach=True)
        with open('%s.asc' % s_filename, 'wb') as handle:
            handle.write(str(signature))
    finally:
        if 'plaintext' in locals():
            plaintext.close()
开发者ID:akissa,项目名称:sachannelupdate,代码行数:17,代码来源:base.py

示例3: sign_content

# 需要导入模块: from gnupg import GPG [as 别名]
# 或者: from gnupg.GPG import sign_file [as 别名]
def sign_content(path, keyring, key, passphrase, output_dir, output_ext='sig'):
    """ Sign the content at specified path using provided keyring
    :param path:        path of the content file
    :param keyring:     keyring path to use
    :param key:         key id
    :param passphrase:  key passphrase
    :param output_dir:  directory in which to write the signed file
    :param output_ext:  extension of the signed file
    """
    name = os.path.splitext(os.path.basename(path))[0]
    gpg = GPG(gnupghome=keyring)
    with open(path, 'rb') as content:
        signed = gpg.sign_file(content, keyid=key, passphrase=passphrase,
                               binary=True, clearsign=False)
    new_path = os.path.join(output_dir, name + '.' + output_ext)
    with open(new_path, 'wb') as output:
        output.write(signed.data)
    return new_path
开发者ID:Outernet-Project,项目名称:artexin,代码行数:20,代码来源:content_crypto.py


注:本文中的gnupg.GPG.sign_file方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。