decryptFile static method

Future<Map<String, dynamic>> decryptFile({
  1. required String encryptedFilePath,
  2. required String decryptedFilePath,
  3. required String secureKey,
  4. String? expectedMD5,
})

解密补丁文件(包含密钥转换和文件解密的完整流程) encryptedFilePath 加密文件路径 decryptedFilePath 解密后文件保存路径 secureKey 原始加密密钥(会在原生端自动转换) expectedMD5 期望的MD5值(可选) 返回 Map,包含 'success' (bool) 和 'errorMessage' (String,失败时提供)

可能抛出 PlatformException 当原生平台调用失败时 可能抛出 ArgumentError 当参数无效时

Implementation

static Future<Map<String, dynamic>> decryptFile({
  required String encryptedFilePath,
  required String decryptedFilePath,
  required String secureKey,
  String? expectedMD5,
}) async {
  try {
    final result = await _channel.invokeMethod(
      'decryptFile',
      {
        'encryptedFilePath': encryptedFilePath,
        'decryptedFilePath': decryptedFilePath,
        'secureKey': secureKey,
        'expectedMD5': expectedMD5 ?? '',
      },
    );

    return Map<String, dynamic>.from(result);
  } on PlatformException catch (e) {
    throw PlatformException(
      code: e.code,
      message: '解密文件失败: ${e.message}',
      details: e.details,
    );
  } catch (e) {
    throw Exception('解密文件时发生未知错误: $e');
  }
}