diff options
author | Ben McGinnes <[email protected]> | 2018-03-21 14:12:36 +0000 |
---|---|---|
committer | Ben McGinnes <[email protected]> | 2018-03-21 14:12:36 +0000 |
commit | 1d2746433c9632fc0c7bc10b59280fca15895545 (patch) | |
tree | ebcfa9373b79bd6000c1c07c200359a0ca1523e5 | |
parent | example: sign file (diff) | |
download | gpgme-1d2746433c9632fc0c7bc10b59280fca15895545.tar.gz gpgme-1d2746433c9632fc0c7bc10b59280fca15895545.zip |
doc: python bindings howto
* deconstructed and fixed all three signing methods.
-rw-r--r-- | lang/python/docs/GPGMEpythonHOWTOen.org | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/lang/python/docs/GPGMEpythonHOWTOen.org b/lang/python/docs/GPGMEpythonHOWTOen.org index 2a200bb7..0c151495 100644 --- a/lang/python/docs/GPGMEpythonHOWTOen.org +++ b/lang/python/docs/GPGMEpythonHOWTOen.org @@ -750,11 +750,10 @@ text = text0.encode() c = gpg.Context(armor=True, signers=sig_src) - signed = c.sign(text, mode=gpg.constants.sig.mode.NORMAL) + signed_data, result = c.sign(text, mode=gpg.constants.sig.mode.NORMAL) with open("/path/to/statement.txt.asc", "w") as afile: - for line in signed[0]: - afile.write("{0}\n".format(line.decode())) + afile.write(signed_data.decode()) #+end_src Though everything in this example is accurate, it is more likely @@ -769,10 +768,10 @@ text = tfile.read() c = gpg.Context() - signed = c.sign(text, mode=gpg.constants.sig.mode.NORMAL) + signed_data, result = c.sign(text, mode=gpg.constants.sig.mode.NORMAL) with open("/path/to/statement.txt.sig", "wb") as afile: - afile.write(signed[0]) + afile.write(signed_data) #+end_src @@ -795,11 +794,10 @@ text = text0.encode() c = gpg.Context(armor=True) - signed = c.sign(text, mode=gpg.constants.sig.mode.DETACH) + signed_data, result = c.sign(text, mode=gpg.constants.sig.mode.DETACH) with open("/path/to/statement.txt.asc", "w") as afile: - for line in signed[0].splitlines(): - afile.write("{0}\n".format(line.decode())) + afile.write(signed_data.decode()) #+end_src As with normal signatures, detached signatures are best handled as @@ -812,10 +810,10 @@ text = tfile.read() c = gpg.Context(signers=sig_src) - signed = c.sign(text, mode=gpg.constants.sig.mode.DETACH) + signed_data, result = c.sign(text, mode=gpg.constants.sig.mode.DETACH) with open("/path/to/statement.txt.sig", "wb") as afile: - afile.write(signed[0]) + afile.write(signed_data) #+end_src @@ -838,11 +836,10 @@ text = text0.encode() c = gpg.Context() - signed = c.sign(text, mode=gpg.constants.sig.mode.CLEAR) + signed_data, result = c.sign(text, mode=gpg.constants.sig.mode.CLEAR) with open("/path/to/statement.txt.asc", "w") as afile: - for line in signed[0].splitlines(): - afile.write("{0}\n".format(line.decode())) + afile.write(signed_data.decode()) #+end_src In spite of the appearance of a clear-signed message, the data @@ -855,10 +852,10 @@ text = tfile.read() c = gpg.Context() - signed = c.sign(text, mode=gpg.constants.sig.mode.CLEAR) + signed_data, result = c.sign(text, mode=gpg.constants.sig.mode.CLEAR) with open("/path/to/statement.txt.asc", "wb") as afile: - afile.write(signed[0]) + afile.write(signed_data) #+end_src |