Symmetric encryption example
* lang/python/examples/howto/symcrypt-file.py: Fixed the error code and the passphrase key word arg.
This commit is contained in:
parent
ed5ef8293c
commit
a256d84882
@ -46,18 +46,18 @@ with open(filename, "rb") as f:
|
|||||||
|
|
||||||
with gpg.Context(armor=True) as ca:
|
with gpg.Context(armor=True) as ca:
|
||||||
try:
|
try:
|
||||||
ciphertext, result, sign_result = ca.encrypt(text, passphrase=None,
|
ciphertext, result, sign_result = ca.encrypt(text, passphrase=True,
|
||||||
sign=False)
|
sign=False)
|
||||||
with open("{0}.asc".format(filename), "wb") as fa:
|
with open("{0}.asc".format(filename), "wb") as fa:
|
||||||
fa.write(ciphertext)
|
fa.write(ciphertext)
|
||||||
except gpg.errors.InvalidRecipients as e:
|
except gpg.errors.GPGMEError as e:
|
||||||
print(e)
|
print(e)
|
||||||
|
|
||||||
with gpg.Context() as cg:
|
with gpg.Context() as cg:
|
||||||
try:
|
try:
|
||||||
ciphertext, result, sign_result = cg.encrypt(text, passphrase=None,
|
ciphertext, result, sign_result = cg.encrypt(text, passphrase=True,
|
||||||
sign=False)
|
sign=False)
|
||||||
with open("{0}.gpg".format(filename), "wb") as fg:
|
with open("{0}.gpg".format(filename), "wb") as fg:
|
||||||
fg.write(ciphertext)
|
fg.write(ciphertext)
|
||||||
except gpg.errors.InvalidRecipients as e:
|
except gpg.errors.GPGMEError as e:
|
||||||
print(e)
|
print(e)
|
||||||
|
Loading…
Reference in New Issue
Block a user