Flutter archive: unzip password-protected folder

1,441

You can try

Archive archive = ZipDecoder().decodeBytes(
   _myDownloadedData,
   verify: true,
   password: "mySuperSecretPsw", )
Share:
1,441
Pado
Author by

Pado

Updated on December 12, 2022

Comments

  • Pado
    Pado over 1 year

    In my flutter application I have to download a password-protected zip folder from a remote server and import the .sqlite that is inside in my app.

    I'm trying with archive library, but of course I'm open for a better solution if any.

    I used the password parameter of ZipDecoder().decodeBytes() method, but it is not working for me.

    //inside the `onDone()` callback of an http request
    Archive archive = ZipDecoder().decodeBytes(
        _myDownloadedData,
        password: "mySuperSecretPsw", //here I set the archive psw
    );
    Uint8List fileDbBytes = Uint8List.fromList(archive.first.content);
    setAsWorkingDb(fileDbBytes);
    

    The archive.first.content from the snippet above looks still encrypted. I get the following errors:

    E/SQLiteLog(12256): (26) file is encrypted or is not a database
    E/DefaultDatabaseErrorHandler(12256): Corruption reported by sqlite on database: /data/user/0/my.own.package/app_flutter/working_data.db
    E/DefaultDatabaseErrorHandler(12256): deleting the database file: /data/user/0/my.own.package/app_flutter/working_data.db
    
  • Pado
    Pado over 4 years
    verify param as far as i know only checks the checksum of the file for integrity