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!
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With