feat: Bring over the cryptography API from moxplatform
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import 'dart:io';
|
||||
import 'dart:typed_data';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:moxxy_native/moxxy_native.dart';
|
||||
|
||||
@@ -5,9 +7,16 @@ void main() {
|
||||
runApp(const MyApp());
|
||||
}
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
class MyApp extends StatefulWidget {
|
||||
const MyApp({super.key});
|
||||
|
||||
@override
|
||||
MyAppState createState() => MyAppState();
|
||||
}
|
||||
|
||||
class MyAppState extends State<MyApp> {
|
||||
String? imagePath;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
@@ -44,6 +53,48 @@ class MyApp extends StatelessWidget {
|
||||
},
|
||||
child: const Text('Generic multi-picker'),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
final result = await MoxxyPickerApi().pickFiles(FilePickerType.image, false);
|
||||
if (result.isEmpty) return;
|
||||
|
||||
final encDest = result.first! + '.enc';
|
||||
final decDest = result.first! + '.dec';
|
||||
final encResult = await MoxxyCryptographyApi().encryptFile(
|
||||
result.first!,
|
||||
encDest,
|
||||
Uint8List.fromList(List.filled(32, 1)),
|
||||
Uint8List.fromList(List.filled(16, 2)),
|
||||
CipherAlgorithm.aes256CbcPkcs7,
|
||||
'SHA-256',
|
||||
);
|
||||
if (encResult == null) {
|
||||
print('Failed to encrypt file');
|
||||
return;
|
||||
}
|
||||
|
||||
final decResult = await MoxxyCryptographyApi().decryptFile(
|
||||
encDest,
|
||||
decDest,
|
||||
Uint8List.fromList(List.filled(32, 1)),
|
||||
Uint8List.fromList(List.filled(16, 2)),
|
||||
CipherAlgorithm.aes256CbcPkcs7,
|
||||
'SHA-256',
|
||||
);
|
||||
if (decResult == null) {
|
||||
print('Failed to decrypt file');
|
||||
return;
|
||||
}
|
||||
|
||||
setState(() {
|
||||
imagePath = decDest;
|
||||
});
|
||||
},
|
||||
child: Text('Test cryptography'),
|
||||
),
|
||||
|
||||
if (imagePath != null)
|
||||
Image.file(File(imagePath!)),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
0
example/pigeon/cryptography.dart
Normal file
0
example/pigeon/cryptography.dart
Normal file
@@ -130,54 +130,6 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.8.2"
|
||||
permission_handler:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: permission_handler
|
||||
sha256: bc56bfe9d3f44c3c612d8d393bd9b174eb796d706759f9b495ac254e4294baa5
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "10.4.5"
|
||||
permission_handler_android:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: permission_handler_android
|
||||
sha256: "59c6322171c29df93a22d150ad95f3aa19ed86542eaec409ab2691b8f35f9a47"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "10.3.6"
|
||||
permission_handler_apple:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: permission_handler_apple
|
||||
sha256: "99e220bce3f8877c78e4ace901082fb29fa1b4ebde529ad0932d8d664b34f3f5"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "9.1.4"
|
||||
permission_handler_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: permission_handler_platform_interface
|
||||
sha256: f2343e9fa9c22ae4fd92d4732755bfe452214e7189afcc097380950cf567b4b2
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.11.5"
|
||||
permission_handler_windows:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: permission_handler_windows
|
||||
sha256: cc074aace208760f1eee6aa4fae766b45d947df85bc831cde77009cdb4720098
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.1.3"
|
||||
plugin_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: plugin_platform_interface
|
||||
sha256: da3fdfeccc4d4ff2da8f8c556704c08f912542c5fb3cf2233ed75372384a034d
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.6"
|
||||
sky_engine:
|
||||
dependency: transitive
|
||||
description: flutter
|
||||
@@ -241,4 +193,4 @@ packages:
|
||||
version: "2.1.4"
|
||||
sdks:
|
||||
dart: ">=2.19.6 <3.0.0"
|
||||
flutter: ">=2.8.0"
|
||||
flutter: ">=2.5.0"
|
||||
|
||||
Reference in New Issue
Block a user