Created
February 21, 2018 15:06
-
-
Save koutoftimer/24daf648f1d1638ca1fbbf8e03350818 to your computer and use it in GitHub Desktop.
Decrypt GPG encrypted mail
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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