aboutsummaryrefslogtreecommitdiffstats
path: root/lang/python/docs/GPGMEpythonHOWTOen.org
diff options
context:
space:
mode:
authorBen McGinnes <[email protected]>2018-03-08 20:53:57 +0000
committerBen McGinnes <[email protected]>2018-03-08 20:53:57 +0000
commitfa4927146b68dd045903285f1c45fb64deb2e361 (patch)
tree6e95ee47b6b8be622c495f0f38c787fb8db7aa2a /lang/python/docs/GPGMEpythonHOWTOen.org
parentdoc: python bindings howto update (diff)
downloadgpgme-fa4927146b68dd045903285f1c45fb64deb2e361.tar.gz
gpgme-fa4927146b68dd045903285f1c45fb64deb2e361.zip
docs: python bindings howto update.
* Added all four signing code examples that are most likely to be used: armoured, clearsigned, detached armoured and detached binary. * May remove some examples and just discuss the differences, but it depends on the way the text is filled out.
Diffstat (limited to 'lang/python/docs/GPGMEpythonHOWTOen.org')
-rw-r--r--lang/python/docs/GPGMEpythonHOWTOen.org90
1 files changed, 90 insertions, 0 deletions
diff --git a/lang/python/docs/GPGMEpythonHOWTOen.org b/lang/python/docs/GPGMEpythonHOWTOen.org
index ab7e9db8..17ec428e 100644
--- a/lang/python/docs/GPGMEpythonHOWTOen.org
+++ b/lang/python/docs/GPGMEpythonHOWTOen.org
@@ -338,6 +338,96 @@ Python bindings to programmatically leverage the GPGME library.
pass
#+end_src
+** Signing text
+ :PROPERTIES:
+ :CUSTOM_ID: howto-basic-signing
+ :END:
+
+ Need to determine whether or not to include clearsigning and
+ detached signing here or give them separate sections.
+
+ #+begin_src python
+ import gpg
+
+ text = """Declaration of ... something.
+
+ """
+
+ c = gpg.Context()
+ c.armor = True
+ signed = c.sign(text, mode=mode.NORMAL)
+
+ afile = open("/path/to/statement.txt.asc", "w")
+ for i in range(len(signed[0].splitlines())):
+ afile.write("{0}\n".format(signed[0].splitlines()[i].decode('utf-8')))
+ afile.close()
+ #+end_src
+
+ Clearsigning:
+
+ #+begin_src python
+ import gpg
+
+ text = """Declaration of ... something.
+
+ """
+
+ c = gpg.Context()
+ c.armor = True
+ signed = c.sign(text, mode=mode.CLEAR)
+
+ afile = open("/path/to/statement.txt.asc", "w")
+ for i in range(len(signed[0].splitlines())):
+ afile.write("{0}\n".format(signed[0].splitlines()[i].decode('utf-8')))
+ afile.close()
+ #+end_src
+
+ Detached ASCII Armoured signing:
+
+ #+begin_src python
+ import gpg
+
+ text = """Declaration of ... something.
+
+ """
+
+ c = gpg.Context()
+ c.armor = True
+ signed = c.sign(text, mode=mode.DETACH)
+
+ afile = open("/path/to/statement.txt.asc", "w")
+ for i in range(len(signed[0].splitlines())):
+ afile.write("{0}\n".format(signed[0].splitlines()[i].decode('utf-8')))
+ afile.close()
+ #+end_src
+
+ Detached binary signing (maybe change text to be reading a file's
+ content):
+
+ #+begin_src python
+import gpg
+
+text = """Declaration of ... something.
+
+"""
+
+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()
+ #+end_src
+
+
+** Signature verification
+ :PROPERTIES:
+ :CUSTOM_ID: howto-basic-verification
+ :END:
+
+x
+
* Copyright and Licensing
:PROPERTIES: