meta: Implement access to AES encryption (but fast)
This commit is contained in:
31
packages/moxplatform_android/lib/src/crypto_android.dart
Normal file
31
packages/moxplatform_android/lib/src/crypto_android.dart
Normal file
@@ -0,0 +1,31 @@
|
||||
import 'dart:typed_data';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:moxplatform_platform_interface/moxplatform_platform_interface.dart';
|
||||
|
||||
class AndroidCryptographyImplementation extends CryptographyImplementation {
|
||||
final _methodChannel = const MethodChannel('me.polynom.moxplatform_android');
|
||||
|
||||
@override
|
||||
Future<bool> encryptFile(String sourcePath, String destPath, Uint8List key, Uint8List iv, CipherAlgorithm algorithm) async {
|
||||
final result = await _methodChannel.invokeMethod<bool>('encryptFile', [
|
||||
sourcePath,
|
||||
destPath,
|
||||
key,
|
||||
iv,
|
||||
algorithm.toInt(),
|
||||
]);
|
||||
return result ?? false;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<bool> decryptFile(String sourcePath, String destPath, Uint8List key, Uint8List iv, CipherAlgorithm algorithm) async {
|
||||
final result = await _methodChannel.invokeMethod<bool>('decryptFile', [
|
||||
sourcePath,
|
||||
destPath,
|
||||
key,
|
||||
iv,
|
||||
algorithm.toInt(),
|
||||
]);
|
||||
return result ?? false;
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
import 'package:moxplatform_android/src/crypto_android.dart';
|
||||
import 'package:moxplatform_android/src/isolate_android.dart';
|
||||
import 'package:moxplatform_android/src/media_android.dart';
|
||||
import 'package:moxplatform_platform_interface/moxplatform_platform_interface.dart';
|
||||
@@ -8,6 +9,7 @@ class MoxplatformAndroidPlugin extends MoxplatformInterface {
|
||||
print('MoxplatformAndroidPlugin: Registering implementation');
|
||||
MoxplatformInterface.handler = AndroidIsolateHandler();
|
||||
MoxplatformInterface.media = AndroidMediaScannerImplementation();
|
||||
MoxplatformInterface.crypto = AndroidCryptographyImplementation();
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
Reference in New Issue
Block a user