[git] GPGME - branch, ben/docs/2018-03, updated. gpgme-1.10.0-66-gab81c2d
by Ben McGinnes
cvs at cvs.gnupg.org
Fri Mar 9 05:24:06 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 ab81c2d868bba79fdb8f8d7f576b6bd88c6bdf3c (commit)
from f685cda281c6148072e8a6cd139c990cb041ea3d (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 ab81c2d868bba79fdb8f8d7f576b6bd88c6bdf3c
Author: Ben McGinnes <ben at adversary.org>
Date: Fri Mar 9 15:22:24 2018 +1100
doc: python bindings howto
* Added example for verifying both detached and "in-line" signatures.
diff --git a/lang/python/docs/GPGMEpythonHOWTOen.org b/lang/python/docs/GPGMEpythonHOWTOen.org
index 17ec428..75f1ebd 100644
--- a/lang/python/docs/GPGMEpythonHOWTOen.org
+++ b/lang/python/docs/GPGMEpythonHOWTOen.org
@@ -13,12 +13,12 @@
:CUSTOM_ID: intro
:END:
-Version: 0.0.1-alpha [2018-03-07 Wed]
-Author: Ben McGinnes <ben at gnupg.org>
-Author GPG Key: DB4724E6FA4286C92B4E55C4321E4E2373590E5D
+ Version: 0.0.1-alpha [2018-03-07 Wed]
+ Author: Ben McGinnes <ben at gnupg.org>
+ Author GPG Key: DB4724E6FA4286C92B4E55C4321E4E2373590E5D
-This document provides basic instruction in how to use the GPGME
-Python bindings to programmatically leverage the GPGME library.
+ This document provides basic instruction in how to use the GPGME
+ Python bindings to programmatically leverage the GPGME library.
* GPGME Concepts
@@ -401,23 +401,22 @@ Python bindings to programmatically leverage the GPGME library.
afile.close()
#+end_src
- Detached binary signing (maybe change text to be reading a file's
- content):
+ Detached binary signing of a file.
#+begin_src python
-import gpg
-
-text = """Declaration of ... something.
+ import gpg
-"""
+ tfile = open("/path/to/statement.txt", "r")
+ text = tfile.read()
+ tfile.close()
-c = gpg.Context()
-c.armor = True
-signed = c.sign(text, mode=mode.DETACH)
+ c = gpg.Context()
+ c.armor = True
+ signed = c.sign(text, mode=mode.DETACH)
-afile = open("/path/to/statement.txt.sig", "wb")
-afile.write(signed[0])
-afile.close()
+ afile = open("/path/to/statement.txt.sig", "wb")
+ afile.write(signed[0])
+ afile.close()
#+end_src
@@ -426,7 +425,31 @@ afile.close()
:CUSTOM_ID: howto-basic-verification
:END:
-x
+ Verify a signed file, both detached and not:
+
+ #+begin_src python
+ import gpg
+ import sys
+ import time
+
+ c = gpg.Context()
+
+ data, result = c.verify(open(filename),
+ open(detached_sig_filename)
+ if detached_sig_filename else None)
+
+ for index, sign in enumerate(result.signatures):
+ print("signature", index, ":")
+ print(" summary: %#0x" % (sign.summary))
+ print(" status: %#0x" % (sign.status))
+ print(" timestamp: ", sign.timestamp)
+ print(" timestamp: ", time.ctime(sign.timestamp))
+ print(" fingerprint:", sign.fpr)
+ print(" uid: ", c.get_key(sign.fpr).uids[0].uid)
+
+ if data:
+ sys.stdout.buffer.write(data)
+ #+end_src
* Copyright and Licensing
-----------------------------------------------------------------------
Summary of changes:
lang/python/docs/GPGMEpythonHOWTOen.org | 59 +++++++++++++++++++++++----------
1 file changed, 41 insertions(+), 18 deletions(-)
hooks/post-receive
--
GnuPG Made Easy
http://git.gnupg.org
More information about the Gnupg-commits
mailing list