新增 OTA WatchDog 编排与车队健康/报警后端。
覆盖包库回传、任务下发、CDM 任务同步与报警采集,并为包/任务 ID 与上传文件名加上路径安全校验。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
using System.Security.Cryptography;
|
||||
|
||||
namespace MiGu.Server.Ota;
|
||||
|
||||
public static class OtaHash
|
||||
{
|
||||
/// <summary>与参考 OTA 工具一致:MD5 → Base64,并去掉 '-'。</summary>
|
||||
public static string OfFile(string path)
|
||||
{
|
||||
using var fs = File.OpenRead(path);
|
||||
var hash = MD5.HashData(fs);
|
||||
return Convert.ToBase64String(hash).Replace("-", "", StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
public static string OfBytes(ReadOnlySpan<byte> bytes)
|
||||
{
|
||||
var hash = MD5.HashData(bytes);
|
||||
return Convert.ToBase64String(hash).Replace("-", "", StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
public static string Short(string? hash, int len = 8)
|
||||
{
|
||||
if (string.IsNullOrEmpty(hash)) return "—";
|
||||
return hash.Length <= len ? hash : hash[..len];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user