mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 15:24:35 +01:00
#112 new: check hash during upgrade
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user