doc: python bindings howto
* deconstructed and fixed all three signing methods.
This commit is contained in:
parent
0390ede186
commit
1d2746433c
@ -750,11 +750,10 @@
|
|||||||
text = text0.encode()
|
text = text0.encode()
|
||||||
|
|
||||||
c = gpg.Context(armor=True, signers=sig_src)
|
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:
|
with open("/path/to/statement.txt.asc", "w") as afile:
|
||||||
for line in signed[0]:
|
afile.write(signed_data.decode())
|
||||||
afile.write("{0}\n".format(line.decode()))
|
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
Though everything in this example is accurate, it is more likely
|
Though everything in this example is accurate, it is more likely
|
||||||
@ -769,10 +768,10 @@
|
|||||||
text = tfile.read()
|
text = tfile.read()
|
||||||
|
|
||||||
c = gpg.Context()
|
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:
|
with open("/path/to/statement.txt.sig", "wb") as afile:
|
||||||
afile.write(signed[0])
|
afile.write(signed_data)
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
|
|
||||||
@ -795,11 +794,10 @@
|
|||||||
text = text0.encode()
|
text = text0.encode()
|
||||||
|
|
||||||
c = gpg.Context(armor=True)
|
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:
|
with open("/path/to/statement.txt.asc", "w") as afile:
|
||||||
for line in signed[0].splitlines():
|
afile.write(signed_data.decode())
|
||||||
afile.write("{0}\n".format(line.decode()))
|
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
As with normal signatures, detached signatures are best handled as
|
As with normal signatures, detached signatures are best handled as
|
||||||
@ -812,10 +810,10 @@
|
|||||||
text = tfile.read()
|
text = tfile.read()
|
||||||
|
|
||||||
c = gpg.Context(signers=sig_src)
|
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:
|
with open("/path/to/statement.txt.sig", "wb") as afile:
|
||||||
afile.write(signed[0])
|
afile.write(signed_data)
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
|
|
||||||
@ -838,11 +836,10 @@
|
|||||||
text = text0.encode()
|
text = text0.encode()
|
||||||
|
|
||||||
c = gpg.Context()
|
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:
|
with open("/path/to/statement.txt.asc", "w") as afile:
|
||||||
for line in signed[0].splitlines():
|
afile.write(signed_data.decode())
|
||||||
afile.write("{0}\n".format(line.decode()))
|
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
In spite of the appearance of a clear-signed message, the data
|
In spite of the appearance of a clear-signed message, the data
|
||||||
@ -855,10 +852,10 @@
|
|||||||
text = tfile.read()
|
text = tfile.read()
|
||||||
|
|
||||||
c = gpg.Context()
|
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:
|
with open("/path/to/statement.txt.asc", "wb") as afile:
|
||||||
afile.write(signed[0])
|
afile.write(signed_data)
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user