|
@@ -1,6 +1,7 @@
|
|
|
import 'dart:io' as io;
|
|
|
import 'dart:typed_data';
|
|
|
|
|
|
+import "package:computer/computer.dart";
|
|
|
import 'package:dio/dio.dart';
|
|
|
import 'package:logging/logging.dart';
|
|
|
import 'package:photos/core/configuration.dart';
|
|
@@ -70,3 +71,26 @@ Uint8List getFileKey(ente.File file) {
|
|
|
CollectionsService.instance.getCollectionKey(file.collectionID!);
|
|
|
return CryptoUtil.decryptSync(encryptedKey, collectionKey, nonce);
|
|
|
}
|
|
|
+
|
|
|
+Future<Uint8List> getFileKeyUsingBgWorker(ente.File file) async {
|
|
|
+ final collectionKey =
|
|
|
+ CollectionsService.instance.getCollectionKey(file.collectionID!);
|
|
|
+ return await Computer.shared().compute(
|
|
|
+ _decryptFileKey,
|
|
|
+ param: <String, dynamic>{
|
|
|
+ "encryptedKey": file.encryptedKey,
|
|
|
+ "keyDecryptionNonce": file.keyDecryptionNonce,
|
|
|
+ "collectionKey": collectionKey,
|
|
|
+ },
|
|
|
+ );
|
|
|
+}
|
|
|
+
|
|
|
+Uint8List _decryptFileKey(Map<String, dynamic> args) {
|
|
|
+ final encryptedKey = CryptoUtil.base642bin(args["encryptedKey"]);
|
|
|
+ final nonce = CryptoUtil.base642bin(args["keyDecryptionNonce"]);
|
|
|
+ return CryptoUtil.decryptSync(
|
|
|
+ encryptedKey,
|
|
|
+ args["collectionKey"],
|
|
|
+ nonce,
|
|
|
+ );
|
|
|
+}
|