'How to read all zipfile in python
I have a zipfile for example, i changed some files in zip and i need to encrypt it and after that save
def encrypt(self, zipfile: ZipFile):
import base64
with open(self.__db_path, 'wb') as db_file:
decrypted_data = zipfile.read()
aes = AES.new(self.key, AES.MODE_OFB)
encrypted_data = aes.encrypt(decrypted_data)
with open(self.__db_path, 'wb') as db_file:
db_file.write(encrypted_data)
But this code throwing the exception, cause code expected argument "name" to read some files into the zip How i can read all zip file to encrypt it and save?
Solution 1:[1]
You should actually specify the name of your zipfile when using .write
method.
The last line would be
db_file.write(encrypted_data, zipfile)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Maxiboi |