From c92da2c7eb148ce9fb06495a8470dd9caf662f9a Mon Sep 17 00:00:00 2001 From: Ben McGinnes Date: Tue, 13 Mar 2018 19:20:44 +1100 Subject: [PATCH] doc: python bindings howto * Added key selection for specifying signing key or keys. --- lang/python/docs/GPGMEpythonHOWTOen.org | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/lang/python/docs/GPGMEpythonHOWTOen.org b/lang/python/docs/GPGMEpythonHOWTOen.org index 5ee3a82b..ea1b7653 100644 --- a/lang/python/docs/GPGMEpythonHOWTOen.org +++ b/lang/python/docs/GPGMEpythonHOWTOen.org @@ -532,9 +532,7 @@ :CUSTOM_ID: howto-basic-signing :END: - Need to determine whether or not to include clearsigning and - detached signing here or give them separate sections. Yes, section - them. + X *** Signing key selection :PROPERTIES: @@ -547,6 +545,19 @@ available it may be necessary to specify the key or keys with which to sign messages and files. + #+begin_src python + import gpg + + logrus = input("Enter the email address or string to match signing keys to: ") + hancock = gpg.Context().keylist(pattern=logrus, secret=True) + sig_src = list(hancock) + #+end_src + + The signing examples in the following sections include the + explicitly designated =signers= parameter in two of the five + examples; once where the resulting signature would be ASCII + armoured and once where it would not be armoured. + *** Normal or default signing messages or files :PROPERTIES: :CUSTOM_ID: howto-basic-signing-normal @@ -559,8 +570,7 @@ """ - c = gpg.Context() - c.armor = True + c = gpg.Context(armor=True, signers=sig_src) signed = c.sign(text, mode=0) afile = open("/path/to/statement.txt.asc", "wb") @@ -598,8 +608,7 @@ """ - c = gpg.Context() - c.armor = True + c = gpg.Context(armor=True) signed = c.sign(text, mode=1) afile = open("/path/to/statement.txt.asc", "wb") @@ -617,7 +626,7 @@ text = tfile.read() tfile.close() - c = gpg.Context() + c = gpg.Context(signers=sig_src) signed = c.sign(text, mode=1) afile = open("/path/to/statement.txt.sig", "wb")