Pre-populated encrypted database with compression ??
Is your feature request related to a problem? Please describe.
To prevent stealing of data, it is better to ship apps with encrypted databases. However, encrypted databases are not compressed.
A non encrypted db of size 50MB can be compressed to 10MB size using gzip.
What strategy do you suggest to ship apps with encrypted + compressed data ?
Describe the solution you'd like
-
Pack Compressed + Encrypted sql dump into assets folder.
-
When initialising the app, create encrypted db from the dump.
-
I am also using FTS5 to provide offline FTS for the app. Is it advised to create 500MB db with mainly FTS5 tables on the native devices ? Or better to ship pre populated data ? How to handle compression then ?
Current Libs
drift: ^2.9.0
sqlcipher_flutter_libs: ^0.5.6
sqlite3: ^2.0.0
Pack Compressed + Encrypted sql dump into assets folder.
That's a step you have to implement yourself.
When initialising the app, create encrypted db from the dump.
LazyDatabase(() async {
final File dbFile = await pathToMyDatabaseFile();
if (!await dbFile.exists()) {
await dbFile.create();
final data = await rootBundle.load('initial_db.db.gz');
final asBytes = data.buffer.asUint8List(data.offsetInBytes, data.lengthInBytes);
await Stream<List<int>>.value(asBytes).transform(GZipCodec().decoder).pipe(file.openWrite());
}
return await NativeDatabase.createInbackground(dbFile, setup: yourCallbackToSetEncryptionKeys);
});
Is it advised to create 500MB db with mainly FTS5 tables on the native devices
500MB of app data is a lot, whether you can do that depends on the expectations your users have on the size consumed by your app. If it consumes less data, shipping prep-populated indexes may be better but I don't fully understand what you mean with that.