encryptDatabase method

Future<void> encryptDatabase(
  1. String key, {
  2. Iterable<String> alsoFiles = const <String>[],
})

Encrypts in place, with key, the unencrypted application database and the files DiscData saved by name (it keeps their list), then keeps using key. Files saved by name before 2.1 are not in that list: pass their names in alsoFiles. Nothing else in the files folder is touched (on Android it is shared with other plugins). Safe to call again after an interruption: what is already encrypted is kept, the rest is encrypted.

Implementation

Future<void> encryptDatabase(
  String key, {
  Iterable<String> alsoFiles = const <String>[],
}) async {
  final String name = await _currentDatabaseName();
  _key = key;
  await closeDB();
  await _backend.encryptInPlace(name, key, _options);
  DiscData.instance;
  await EncryptionHooks.encryptExistingFiles?.call(alsoFiles);
}