docs python bindings howto
* PEP8 compliance: a collection of minor edits across multiple example code snippets.
This commit is contained in:
parent
5cd4193418
commit
2f507b0459
@ -165,7 +165,7 @@
|
|||||||
This package is the origin of these bindings, though they are
|
This package is the origin of these bindings, though they are
|
||||||
somewhat different now. For details of when and how the PyME
|
somewhat different now. For details of when and how the PyME
|
||||||
package was folded back into GPGME itself see the /Short History/
|
package was folded back into GPGME itself see the /Short History/
|
||||||
document[fn:1] in this Python bindings =docs= directory.[fn:2]
|
document[fn:1] in the Python bindings =docs= directory.[fn:2]
|
||||||
|
|
||||||
The PyME package was first released in 2002 and was also the first
|
The PyME package was first released in 2002 and was also the first
|
||||||
attempt to implement a low level binding to GPGME. In doing so it
|
attempt to implement a low level binding to GPGME. In doing so it
|
||||||
@ -537,8 +537,7 @@
|
|||||||
c = gpg.Context(armor=True)
|
c = gpg.Context(armor=True)
|
||||||
rkey = list(c.keylist(pattern=a_key, secret=False))
|
rkey = list(c.keylist(pattern=a_key, secret=False))
|
||||||
ciphertext, result, sign_result = c.encrypt(text, recipients=rkey,
|
ciphertext, result, sign_result = c.encrypt(text, recipients=rkey,
|
||||||
sign=True, always_trust=True,
|
sign=True, always_trust=True, add_encrypt_to=True)
|
||||||
add_encrypt_to=True)
|
|
||||||
|
|
||||||
with open("secret_plans.txt.asc", "wb") as afile:
|
with open("secret_plans.txt.asc", "wb") as afile:
|
||||||
afile.write(ciphertext)
|
afile.write(ciphertext)
|
||||||
@ -630,7 +629,8 @@
|
|||||||
logrus.append(rpattern[i])
|
logrus.append(rpattern[i])
|
||||||
|
|
||||||
try:
|
try:
|
||||||
ciphertext, result, sign_result = c.encrypt(text, recipients=logrus, add_encrypt_to=True)
|
ciphertext, result, sign_result = c.encrypt(text, recipients=logrus,
|
||||||
|
add_encrypt_to=True)
|
||||||
except gpg.errors.InvalidRecipients as e:
|
except gpg.errors.InvalidRecipients as e:
|
||||||
for i in range(len(e.recipients)):
|
for i in range(len(e.recipients)):
|
||||||
for n in range(len(logrus)):
|
for n in range(len(logrus)):
|
||||||
@ -639,7 +639,8 @@
|
|||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
try:
|
try:
|
||||||
ciphertext, result, sign_result = c.encrypt(text, recipients=logrus, add_encrypt_to=True)
|
ciphertext, result, sign_result = c.encrypt(text, recipients=logrus,
|
||||||
|
add_encrypt_to=True)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -670,8 +671,10 @@
|
|||||||
|
|
||||||
ciphertext = input("Enter path and filename of encrypted file: ")
|
ciphertext = input("Enter path and filename of encrypted file: ")
|
||||||
newfile = input("Enter path and filename of file to save decrypted data to: ")
|
newfile = input("Enter path and filename of file to save decrypted data to: ")
|
||||||
|
|
||||||
with open(ciphertext, "rb") as cfile:
|
with open(ciphertext, "rb") as cfile:
|
||||||
plaintext, result, verify_result = gpg.Context().decrypt(cfile)
|
plaintext, result, verify_result = gpg.Context().decrypt(cfile)
|
||||||
|
|
||||||
with open(newfile, "wb") as nfile:
|
with open(newfile, "wb") as nfile:
|
||||||
nfile.write(plaintext)
|
nfile.write(plaintext)
|
||||||
#+end_src
|
#+end_src
|
||||||
|
Loading…
Reference in New Issue
Block a user