如何对文件进行签名然后验证?

发布于 2025-01-05 03:34:32 字数 458 浏览 2 评论 0原文

我正在编写一个应用程序,在该应用程序中我将文件同步到我想要签署该文件的服务器,然后将其发送回可以验证该文件的客户端。

Ubuntu/Debian 的 Python 似乎有多个 gnupg 模块:

python-gnupginterface - GnuPG (GPG) 的 Python 接口

python-gpgme - GPGME 库的 python 包装器

python-gpgme-dbg - GPGME 库的 python 包装器(调试扩展) )

python-pyme - GPGME GnuPG 加密库的 Python 接口

python-pyme-doc - GPGME GnuPG 加密库的 Python 接口

有人可以推荐我应该使用哪一个吗这能让我快速启动并运行吗?

我应该直接使用 gpg 而不是使用 Python 模块吗?

谢谢!

I am writing an application in which I sync a file to a server where I want to sign the file then send it back to the client where it can be verified.

There seem to be multiple gnupg modules for Python for Ubuntu/Debian:

python-gnupginterface - Python interface to GnuPG (GPG)

python-gpgme - python wrapper for the GPGME library

python-gpgme-dbg - python wrapper for the GPGME library (debug extension)

python-pyme - Python interface to the GPGME GnuPG encryption library

python-pyme-doc - Python interface to the GPGME GnuPG encryption library

Can someone recommend which I one I should use that gets me up and running quickly?

Should I just shell out to gpg instead of using a Python module?

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

〗斷ホ乔殘χμё〖 2025-01-12 03:34:32

使用 python-gpgme (作为奖励,您可能认识维护者)。

以下是如何使用它来签署某些内容(如果有更好的方法,请与 jamesh 联系,我没有广泛使用它):

import gpgme
from io import BytesIO

ctx = gpgme.Context()
plain = BytesIO("Hello")
sign = BytesIO("")

ctx.sign(plain, sign, gpgme.SIG_MODE_CLEAR)
print sign.getvalue()

如果不清楚,BytesIO 是一个类似文件的东西。您可以将 file("/etc/passwd") 作为普通格式,将 sys.stdout 作为符号,它就是 DWYW。

Use python-gpgme (as a bonus, you probably know the maintainer).

Here's how you can use it to sign something (check with jamesh if there's a better way, I haven't use this extensively):

import gpgme
from io import BytesIO

ctx = gpgme.Context()
plain = BytesIO("Hello")
sign = BytesIO("")

ctx.sign(plain, sign, gpgme.SIG_MODE_CLEAR)
print sign.getvalue()

in case it's not clear, BytesIO is a file-like thing. You could give it file("/etc/passwd") as plain and sys.stdout as sign and it'd DWYW.

忘羡 2025-01-12 03:34:32

您可以使用 http://code.google.com/p/python-gnupg/

它包装了命令行 GnuPG。我用它来加密/签名和解密/验证文件。

You can use http://code.google.com/p/python-gnupg/

It wraps command line GnuPG. I use it to encrypt/sign and decrypt/verify files.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文