I am trying to send a password protected zip file as a base64 string.
data = BytesIO()
zip = zipfile.ZipFile(data, 'w')
zip.writestr('test.csv', 'Hello, World')
zip.setpassword(b'1234')
zip.close()
b64zip = base64.b64encode(data.getvalue()).decode('utf-8')
This b64zip
variable is then parsed as an email attachment.
However, when I try to unzip the zip it doesn't prompt for a password. Was using this thread for reference: zipfile: how to set a password for a Zipfile?
How can I create a password protected zip file as a base64 string?