Skip to main content

tinygpgs

tinygpgs is a fast module and standalone Python 2 script for doing symmetric key (passphrase-based) encryption and decryption using the OpenPGP file format compatible with GPG (GnuPG).

Usage

File class API usage for encryption:

import getpass
from tinygpgs.file import GpgSymmetricFile
f = GpgSymmetricFile('FILE.bin.gpg', 'wb', getpass.getpass())
try:
  f.write('Hello, World!\n')
  f.write('This is the end.\n')
finally:
  f.close()

File class API usage for decryption:

import getpass
from tinygpgs.file import GpgSymmetricFile
f = GpgSymmetricFile('FILE.bin', 'rb', getpass.getpass())
try:
  # Use f.read(8192) in a loop instead to limit memory usage.
  print(f.read())
finally:
  f.close()

For encryption, it also provides the encryptedfile 1.1.1 interface for easy migration:

import getpass
from tinygpgs.file import EncryptedFile  # Just for compatibility.
f = EncryptedFile('FILE.bin.gpg', mode='wb', passphrase=getpass.getpass())
try:
  f.write('Hello, World!\n')
  f.write('This is the end.\n')
finally:
  f.close()

Command-line tool usage:

$ python -m tinygpgs -c FILE.bin                  # Encrypt.
Enter passphrase:
$ python -m tinygpgs -d <FILE.bin.gpg >FILE2.bin  # Decrypt.
Enter passphrase:
$ cmp FILE.bin FILE2.bin

The command-line tool has many flags identical to gpg(1), so you can use python -m tinygpgs as a drop-in replacement for gpg for symmetric key encryption and decryption.

Features

tinygpgs supports all ciphers, hashes, string-to-key modes, output formats (binary and ASCII armor) and compression methods in the OpenPGP RFC for both encryption and decryption. All these settings are configurable in keyword arguments to the class constructors and in command-line flags.

tinygpgs doesn’t support public-key cryptography (e.g. encryption, signing and key generation).

Installation

To get the module, run this:

$ python -m pip install tinygpgs pycrypto

Please note that tinygpgs works without pycrypto as well, but with pycrypto it works much faster, even comparable with gpg(1): less than 1.37 slower.

To get the standalone version of the command-line tool (single executable file for Unix, contains the module embedded), see https://github.com/pts/tinygpgs.

You need Python >=2.4 to use tinygpgs as a script or a module. It was tested with 2.4 and 3.8, and all the major versions in-between.

More info

See see https://github.com/pts/tinygpgs.

License

tinygpgs is free software released under the MIT license. There is NO WARRANTY. Use at your risk.

Metadata

Release files for tinygpgs 0.18

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tinygpgs 0.18
File Size Uploaded Provenance Actions
tinygpgs-0.18.tar.gz 76.8 kB Without provenance Details for tinygpgs-0.18.tar.gz

Release files / tinygpgs-0.18.tar.gz

Download URL tinygpgs-0.18.tar.gz
Size 76.8 kB
Tags Source
SHA-256 checksum
How to use checksums
326b94af47e9c2092434d1d1a6826a66501ba288289809a02199aea6760d6b51
BLAKE2b-256 checksum
How to use checksums
9cb6f76f5f241817fd2ee439f4a7268da27ba27326f17738ad578bc016ad578c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.40.0 CPython/2.7.13

Security for tinygpgs 0.18

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page