diff --git a/lib/utils/crypto_util.dart b/lib/utils/crypto_util.dart index f5ed78c77..0c0fd9fcd 100644 --- a/lib/utils/crypto_util.dart +++ b/lib/utils/crypto_util.dart @@ -1,19 +1,16 @@ import 'dart:typed_data'; import 'dart:io' as io; -import 'package:aes_crypt/aes_crypt.dart'; import 'package:computer/computer.dart'; import 'package:encrypt/encrypt.dart'; import 'package:encrypt/encrypt.dart' as e; import 'package:flutter_sodium/flutter_sodium.dart'; import 'package:logging/logging.dart'; -import 'package:photos/core/configuration.dart'; import 'package:photos/models/encrypted_data_attributes.dart'; import 'package:photos/models/encrypted_file_attributes.dart'; import 'package:photos/models/encryption_attribute.dart'; import 'package:steel_crypt/steel_crypt.dart' as steel; -import 'package:uuid/uuid.dart'; final int encryptionChunkSize = 4 * 1024 * 1024; final int decryptionChunkSize = @@ -185,89 +182,4 @@ class CryptoUtil { iv: IV(iv), ); } - - static Future encryptFileToFile( - String sourcePath, String destinationPath, String password) async { - final args = Map(); - args["password"] = password; - args["source"] = sourcePath; - args["destination"] = destinationPath; - return Computer().compute(runEncryptFileToFile, param: args); - } - - static Future encryptDataToFile( - Uint8List source, String destinationPath, String password) async { - final args = Map(); - args["password"] = password; - args["source"] = source; - args["destination"] = destinationPath; - return Computer().compute(runEncryptDataToFile, param: args); - } - - static Future encryptDataToData( - Uint8List source, String password) async { - final destinationPath = - Configuration.instance.getTempDirectory() + Uuid().v4(); - return encryptDataToFile(source, destinationPath, password).then((value) { - final file = io.File(destinationPath); - final data = file.readAsBytesSync(); - file.deleteSync(); - return data; - }); - } - - static Future decryptFileToFile( - String sourcePath, String destinationPath, String password) async { - final args = Map(); - args["password"] = password; - args["source"] = sourcePath; - args["destination"] = destinationPath; - return Computer().compute(runDecryptFileToFile, param: args); - } - - static Future decryptFileToData( - String sourcePath, String password) { - final args = Map(); - args["password"] = password; - args["source"] = sourcePath; - return Computer().compute(runDecryptFileToData, param: args); - } - - static Future decryptDataToData( - Uint8List source, String password) { - final sourcePath = Configuration.instance.getTempDirectory() + Uuid().v4(); - final file = io.File(sourcePath); - file.writeAsBytesSync(source); - return decryptFileToData(sourcePath, password).then((value) { - file.deleteSync(); - return value; - }); - } -} - -Future runEncryptFileToFile(Map args) { - final encrypter = getEncrypter(args["password"]); - return encrypter.encryptFile(args["source"], args["destination"]); -} - -Future runEncryptDataToFile(Map args) { - final encrypter = getEncrypter(args["password"]); - return encrypter.encryptDataToFile(args["source"], args["destination"]); -} - -Future runDecryptFileToFile(Map args) async { - final encrypter = getEncrypter(args["password"]); - return encrypter.decryptFile(args["source"], args["destination"]); -} - -Future runDecryptFileToData(Map args) async { - final encrypter = getEncrypter(args["password"]); - return encrypter.decryptDataFromFile(args["source"]); -} - -AesCrypt getEncrypter(String password) { - final encrypter = AesCrypt(password); - encrypter.aesSetMode(AesMode.cbc); - encrypter.setOverwriteMode(AesCryptOwMode.on); - return encrypter; } diff --git a/pubspec.lock b/pubspec.lock index 678f98700..8bab87284 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1,13 +1,6 @@ # Generated by pub # See https://dart.dev/tools/pub/glossary#lockfile packages: - aes_crypt: - dependency: "direct main" - description: - name: aes_crypt - url: "https://pub.dartlang.org" - source: hosted - version: "0.1.1" animate_do: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index fa7c8985a..a8be1a9bc 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -23,7 +23,6 @@ dependencies: # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. encrypt: ^4.0.2 - aes_crypt: ^0.1.1 cupertino_icons: ^0.1.2 photo_manager: ^0.5.8 provider: ^3.1.0