docs: python bindings howto DITA
* Updated the decryption example code to include the changes needed to gracefully handle a decryption failure due to MDC-less ciphertext and/or deprecated algorithms. * See also: https://dev.gnupg.org/T3981
This commit is contained in:
parent
27ae87c7cf
commit
dea1ccbc02
@ -17,10 +17,17 @@ ciphertext = input("Enter path and filename of encrypted file: ")
|
||||
newfile = input("Enter path and filename of file to save decrypted data to: ")
|
||||
|
||||
with open(ciphertext, "rb") as cfile:
|
||||
plaintext, result, verify_result = gpg.Context().decrypt(cfile)
|
||||
try:
|
||||
plaintext, result, verify_result = gpg.Context().decrypt(cfile)
|
||||
except gpg.errors.GPGMEError as e:
|
||||
plaintext = None
|
||||
print(e)
|
||||
|
||||
with open(newfile, "wb") as nfile:
|
||||
nfile.write(plaintext)
|
||||
if plaintext is not None:
|
||||
with open(newfile, "wb") as nfile:
|
||||
nfile.write(plaintext)
|
||||
else:
|
||||
pass
|
||||
</codeblock>
|
||||
</p>
|
||||
<p>The data available in <codeph>plaintext</codeph> in this example is the decrypted content
|
||||
|
Loading…
Reference in New Issue
Block a user