Skip to content

Instantly share code, notes, and snippets.

@koutoftimer
Created February 21, 2018 15:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save koutoftimer/24daf648f1d1638ca1fbbf8e03350818 to your computer and use it in GitHub Desktop.
Save koutoftimer/24daf648f1d1638ca1fbbf8e03350818 to your computer and use it in GitHub Desktop.
Decrypt GPG encrypted mail
#!/usr/bin/env python3
import sys
import quopri
import subprocess as sp
def main():
#: Retrieve mail from the clipboard.
#: Depends on your system configuration.
encrypted = sp.Popen(['xclip', '-o'], stdout=sp.PIPE)
raw = sp.Popen(['gpg', '--decrypt'], stdin=encrypted.stdout, stdout=sp.PIPE)
encrypted.stdout.close()
out, err = raw.communicate()
q = quopri.decodestring(out)
print(q.decode('utf-8'))
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment