using System.Security.Cryptography; using AuditPackRecord = StellaOps.AuditPack.Models.AuditPack; namespace StellaOps.AuditPack.Services; public sealed partial class AuditPackBuilder { private static AuditPackRecord WithDigest(AuditPackRecord pack) { var json = CanonicalJson.Serialize(pack with { PackDigest = null, Signature = null }); var digest = ComputeDigest(json); return pack with { PackDigest = digest }; } private static string ComputeDigest(byte[] content) { var hash = SHA256.HashData(content); return Convert.ToHexString(hash).ToLowerInvariant(); } }