Skip to main content

Pretty Good Privacy for Python

Project description

Latest version Travis-CI Coveralls

Homepage: None yet.

PGPy is a Python (2 and 3) library for implementing Pretty Good Privacy into Python programs.


Currently, PGPy can load keys and signatures of all kinds in both ASCII armored and binary formats.

It can sign and verify RSA signatures only, at the moment.


To install PGPy, simply:

$ pip install PGPy


with pubsec.key("DEADBEEF"):
    # You can sign things by specifying a private key.
    # If the key is protected, you may need to unlock it first, otherwise, :py:meth:`PGPKeyring.sign` will raise an exception
    if pubsec.selected_privkey.encrypted:

    # now sign your document. This can be a path, URL, file-like object, string, or bytes.
    sig = pubsec.sign("path/to/document")

    # if you want to write the signature to disk, that's easy too!
    sig.path = "path/to/document.asc"

    # You can verify the signature using the public key half of the same key:
    if pubsec.verify("path/to/document", str(sig)):
        print("Signature in memory verified!")

    # or use the signature you just wrote to disk
    if pubsec.verify("path/to/document", "path/to/document.asc"):
        print("Signature on disk verified!")

# When you exit the context-management block, decrypted secret key material is removed from memory,
# leaving only the encrypted key material.

# When verifying documents with signatures, you don't need to specify a specific key ahead of time.
# PGPy will figure out which key signed it using metadata in the signature:
ubuntupubkeys = pgpy.PGPKeyring("")
with ubuntupubkeys.key():
    # PGPKeyring.verify returns a SignatureVerification object which can be compared directly as a boolean.
    # It also retains some additional information you can use:
    sigv = pubsec.verify("",
    if sigv:
        print("Signature was verified using {key}".format(key=sigv.key.keyid))


PGPy Documentation <>



MIT licensed. See the bundled LICENSE file for more details.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for PGPy, version 0.1.0
Filename, size File type Python version Upload date Hashes
Filename, size PGPy-0.1.0.tar.gz (22.1 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page