Skip to content

Commit

Permalink
UnicodeDecodeError on attachments/keys
Browse files Browse the repository at this point in the history
Don't abort on UnicodeDecodeError (#5) when trying to decrypt an entry with attachments/keys.
  • Loading branch information
GurpreetKang committed Oct 30, 2021
1 parent d935454 commit 3559344
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion BitwardenDecrypt.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,12 @@ def decryptCipherString(CipherString, key, mackey):
decrypted = decryptor.update(ciphertext) + decryptor.finalize()
cleartext = unpadder.update(decrypted) + unpadder.finalize()

return(cleartext.decode('utf-8'))
try:
cleartext = cleartext.decode('utf-8')
except UnicodeDecodeError as e:
cleartext = f"ERROR decrypting: {CipherString}"

return(cleartext)

else:
return("ERROR: MAC did not match. CipherString not decrypted.")
Expand Down

0 comments on commit 3559344

Please sign in to comment.