Using Python 2.17.12, Pycharm and Linux Ubuntu
Want to know how can I decrypt .pgp file to .txt file, using a key(.asc file) in Python Script.
Able to do it in python command line, but want to write a script for it.
import gnupg
gpg = gnupg.GPG(gnupghome='/path/to/directory')
imported key
key_to_import = '.asc key file'
key_data = open(key_to_import).read()
import_result = gpg.import_keys(key_data)
decrypt File
with open('.pgp file name', 'rb') as f:
status = gpg.decrypt_file(f,passphrase='**appropriate_one**', output='.txt file name')
check status
print 'ok: ', status.ok
print 'status: ', status.status
print 'stderr: ', status.stderr
Worked for me, might help someone else.