aboutsummaryrefslogtreecommitdiffstats
path: root/lang/python/docs/GPGMEpythonHOWTOen.org
diff options
context:
space:
mode:
authorBen McGinnes <[email protected]>2018-03-18 21:43:36 +0000
committerBen McGinnes <[email protected]>2018-03-18 21:43:36 +0000
commit82c5af225f2bdf3acc6fc652a96ee61c9b057395 (patch)
treea1e0f1e3cd2f00b0b3c18fd85730c44828de27c8 /lang/python/docs/GPGMEpythonHOWTOen.org
parentdoc: python bindings howto (diff)
downloadgpgme-82c5af225f2bdf3acc6fc652a96ee61c9b057395.tar.gz
gpgme-82c5af225f2bdf3acc6fc652a96ee61c9b057395.zip
doc: python bindings howto
* Stripped decryption example to the bare bones as suggested by Justus.
Diffstat (limited to '')
-rw-r--r--lang/python/docs/GPGMEpythonHOWTOen.org26
1 files changed, 6 insertions, 20 deletions
diff --git a/lang/python/docs/GPGMEpythonHOWTOen.org b/lang/python/docs/GPGMEpythonHOWTOen.org
index d27f5620..a2144235 100644
--- a/lang/python/docs/GPGMEpythonHOWTOen.org
+++ b/lang/python/docs/GPGMEpythonHOWTOen.org
@@ -690,28 +690,14 @@
to =c= simply adds lines for no gain.
#+begin_src python
- import os.path
import gpg
- if os.path.exists("/path/to/secret_plans.txt.asc") is True:
- ciphertext = "/path/to/secret_plans.txt.asc"
- elif os.path.exists("/path/to/secret_plans.txt.gpg") is True:
- ciphertext = "/path/to/secret_plans.txt.gpg"
- else:
- ciphertext = None
-
- if ciphertext is not None:
- afile = open(ciphertext, "rb")
- plaintext = gpg.Context().decrypt(afile)
- afile.close()
- newfile = open("/path/to/secret_plans.txt", "wb")
- newfile.write(plaintext[0])
- newfile.close()
- print(plaintext[0])
- plaintext[1]
- plaintext[2]
- else:
- pass
+ ciphertext = input("Enter path and filename of encrypted file: ")
+ newfile = input("Enter path and filename of file to save decrypted data to: ")
+ with open(ciphertext, "rb") as cfile:
+ plaintext, result, verify_result = gpg.Context().decrypt(cfile)
+ with open(newfile, "wb" as nfile:
+ nfile.write(plaintext)
#+end_src
The data available in plaintext in this example is the decrypted