package crypto import ( "crypto/sha256" "encoding/hex" "slices" "strings" ) // Fingerprint 计算机器指纹摘要(docs/design/04-crypto.md §5)。 // // 输入为原始采集字段;输出 "sha256:" + hex,服务端与日志只见摘要。 // 字段排序后拼接保证顺序无关(采集器返回顺序不稳定)。 func Fingerprint(fields ...string) string { sorted := slices.Clone(fields) slices.Sort(sorted) sum := sha256.Sum256([]byte(strings.Join(sorted, " "))) return "sha256:" + hex.EncodeToString(sum[:]) }