[git] GPGME - branch, ben/docs/2018-03, updated. gpgme-1.10.0-87-gada059b

by Ben McGinnes cvs at cvs.gnupg.org
Wed Mar 14 17:54:05 CET 2018


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GnuPG Made Easy".

The branch, ben/docs/2018-03 has been updated
       via  ada059b07178147821b1598c935aa70ae45e3e6c (commit)
      from  ef27f3781a37e264d0eb7d1745eb2c804ec062c4 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit ada059b07178147821b1598c935aa70ae45e3e6c
Author: Ben McGinnes <ben at adversary.org>
Date:   Thu Mar 15 03:51:51 2018 +1100

    doc: python bindings howto
    
    * Fixed multiple sample code examples of writing output to a file.
    * Added the description of detached signatures.

diff --git a/lang/python/docs/GPGMEpythonHOWTOen.org b/lang/python/docs/GPGMEpythonHOWTOen.org
index 360bce9..71ddbcf 100644
--- a/lang/python/docs/GPGMEpythonHOWTOen.org
+++ b/lang/python/docs/GPGMEpythonHOWTOen.org
@@ -730,22 +730,34 @@
     plaintext is already compressed.  ASCII armouring will be
     determined according to the value of =gpg.Context().armor=.
 
+    The compression algorithm is selected in much the same way as the
+    symmetric encryption algorithm or the hash digest algorithm is
+    when multiple keys are involved; from the preferences saved into
+    the key itself or by comparison with the preferences with all
+    other keys involved.
+
    #+begin_src python
      import gpg
 
-     text = b"""Declaration of ... something.
+     text0 = """Declaration of ... something.
 
      """
+     text = text0.encode("utf-8")
 
      c = gpg.Context(armor=True, signers=sig_src)
      signed = c.sign(text, mode=0)
 
-     afile = open("/path/to/statement.txt.asc", "wb")
-     for i in range(len(signed[0].splitlines())):
-	 afile.write("{0}\n".format(signed[0].splitlines()[i]))
+     afile = open("/path/to/statement.txt.asc", "w")
+     for line in signed[0]:
+	 afile.write("{0}\n".format(line.decode("utf-8")))
      afile.close()
    #+end_src
 
+   Though everything in this example is accurate, it is more likely
+   that reading the input data from another file and writing the
+   result to a new file will be perfprmed more like the way it is done
+   in the next example.  Even if the output format is ASCII armoured.
+
    #+begin_src python
      import gpg
 
@@ -766,40 +778,45 @@
     :CUSTOM_ID: howto-basic-signing-detached
     :END:
 
-   Detached ASCII Armoured signing:
+    Detached signatures will often be needed in programmatic uses of
+    GPGME, either for signing files (e.g. tarballs of code releases)
+    or as a component of message signing (e.g. PGP/MIME encoded
+    email).
 
-   #+begin_src python
-     import gpg
+    #+begin_src python
+      import gpg
 
-     text = b"""Declaration of ... something.
+      text0 = """Declaration of ... something.
 
-     """
+      """
+      text = text0.encode("utf-8")
 
-     c = gpg.Context(armor=True)
-     signed = c.sign(text, mode=1)
+      c = gpg.Context(armor=True)
+      signed = c.sign(text, mode=1)
 
-     afile = open("/path/to/statement.txt.asc", "wb")
-     for i in range(len(signed[0].splitlines())):
-	 afile.write("{0}\n".format(signed[0].splitlines()[i]))
-     afile.close()
-   #+end_src
+      afile = open("/path/to/statement.txt.asc", "w")
+      for line in signed[0].splitlines()L
+	  afile.write("{0}\n".format(line.decode("utf-8")))
+      afile.close()
+    #+end_src
 
-   Detached binary signing of a file.
+    As with normal signatures, detached signatures are best handled as
+    byte literals, even when the output is ASCII armoured.
 
-   #+begin_src python
-     import gpg
+    #+begin_src python
+      import gpg
 
-     tfile = open("/path/to/statement.txt", "rb")
-     text = tfile.read()
-     tfile.close()
+      tfile = open("/path/to/statement.txt", "rb")
+      text = tfile.read()
+      tfile.close()
 
-     c = gpg.Context(signers=sig_src)
-     signed = c.sign(text, mode=1)
+      c = gpg.Context(signers=sig_src)
+      signed = c.sign(text, mode=1)
 
-     afile = open("/path/to/statement.txt.sig", "wb")
-     afile.write(signed[0])
-     afile.close()
-   #+end_src
+      afile = open("/path/to/statement.txt.sig", "wb")
+      afile.write(signed[0])
+      afile.close()
+    #+end_src
 
 *** Clearsigning messages or text
     :PROPERTIES:

-----------------------------------------------------------------------

Summary of changes:
 lang/python/docs/GPGMEpythonHOWTOen.org | 73 ++++++++++++++++++++-------------
 1 file changed, 45 insertions(+), 28 deletions(-)


hooks/post-receive
-- 
GnuPG Made Easy
http://git.gnupg.org




More information about the Gnupg-commits mailing list