Issues Working With Encrypted Zip FIles w/ Python

Viewed 168

I'm using a statement like:

zipf.read(file, pwd = 'password')

Results in an error:

TypeError: pwd: expected bytes, got str

Did some research, determined I should try this:

zipf.read(file, pwd = b'password')

Now results in error:

RuntimeError: Bad password for file <ZipInfo filename='smb-d1674sc2.bin' compress_type=99 external_attr=0x20 file_size=737280 compress_size=641541>

Feel like I am just going in circles at this point. I have also tried:

                password = 'password'
                passwd = password.encode("UTF-8")
                pwd = 'password'.encode('cp850','replace')
                testpass = str(b'password', 'utf-8')

And none of these work either (replacing my string above with these various variables)

Yes, I have tried opening the file on my system manually and can confirm the password is correct.

Additional Background: Working in Lambda, taking in an encrypted zip which is uploaded to S3. My program works with no issues for zips that are not password protected.

0 Answers
Related