Issue:
If the encrypted base64 string is larger than the original file the f.write(data) will expand the file, while the decryption will f.seek(0) to the start of the file and write the original content but will leave a part of the encrypted base64 string at the "end" of the file.
Issue: If the encrypted base64 string is larger than the original file the
f.write(data)
will expand the file, while the decryption willf.seek(0)
to the start of the file and write the original content but will leave a part of the encrypted base64 string at the "end" of the file.fix: Use
f.truncate(0)
in addition tof.seek(0)
steps to reproduce: