0

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?

Dharman
  • 30,962
  • 25
  • 85
  • 135
dangost
  • 13
  • 2

1 Answers1

0

You should actually specify the name of your zipfile when using .write method.

The last line would be

db_file.write(encrypted_data, zipfile)

Maxiboi
  • 150
  • 1
  • 8
  • i mean that i can't get the decrypted data to encrypt it cause i can't get a binary code of my zipfile – dangost Sep 14 '20 at 18:33