#112 new: check hash during upgrade

This commit is contained in:
lollipopkit
2023-08-08 16:31:28 +08:00
parent 693eef8f7e
commit 159942de95
12 changed files with 79 additions and 47 deletions

View File

@@ -1,4 +1,5 @@
import 'dart:io';
import 'package:crypto/crypto.dart';
import 'package:file_picker/file_picker.dart';
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';
@@ -77,3 +78,12 @@ String getTime(int? unixMill) {
String pathJoin(String path1, String path2) {
return path1 + (path1.endsWith('/') ? '' : '/') + path2;
}
Future<String?> getFileSha256(String path) async {
final file = File(path);
if (!(await file.exists())) {
return null;
}
final digest = await sha256.bind(file.openRead()).first;
return digest.toString();
}