简体   繁体   中英

Simplest yet secure way of using gpg in python?

I want to encrypt some plaintext in python using a key that's been generated through the gpg2 commandline. The application will only know the public key, and would encrypt the data before storage into a database.

I know there is python-gnupg, but that's only been tested on gpg 1.4.2. The latest stable is gpg 2.0.19, which adds some new bugfixes and features. There's pycrypto, but that seems bulky to use for a simple encryption step.

I could use the subprocess module and just use gpg2, but I am unsure about the security implications of running external programs from python.

Is there a pure python wrapper for gpg that I can use? Or would using the subprocess module to call gpg2 be sufficient?

You can try python-pgp .

Here are some other alternatives:

  • pyassuan - communicate with GnuPG using its socket protocol.
  • gnupg - a wrapper around the GnuPG executable.
  • python-gnupg - another wrapper around the GnuPG executable.
  • another wrapper around the GnuPG executable.
  • gpglib - a pure python library for parsing OpenPGP packets and decrypting messages.
  • OpenPGP - an unmaintained pure python library with much of the functionality of old versions of GnuPG.
  • encryptedfile - a pure python library for symmetrically encrypting files in an OpenPGP-compatible way.
  • PGPy - a pure python library with basic parsing and signing of OpenPGP packets.
  • OpenPGP-Python - a pure python port of openpgp-php. It can parse OpenPGP packets and verify & create signatures.

But, in my case, none of these will work. If I can find what I am looking for, I will be sure to update this post with a lot more information.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM