Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter archive: unzip password-protected folder

Tags:

io

flutter

dart

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
like image 709
Pado Avatar asked Dec 19 '25 23:12

Pado


1 Answers

You can try

Archive archive = ZipDecoder().decodeBytes(
   _myDownloadedData,
   verify: true,
   password: "mySuperSecretPsw", )
like image 115
ChiaChe Avatar answered Dec 22 '25 15:12

ChiaChe



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!