import CryptoKit import Foundation /// Privacy-safe helpers for log values (SP-2). public enum LogRedaction { /// Returns the first 12 lowercase hex characters of the SHA-256 digest of `value`. /// /// Use this for identifiers that must be correlatable across log lines without revealing /// the original text. Always log the result with `privacy: .private`; SECURITY_PRIVACY /// §Logging requires the private qualifier for correlation hashes as well. public static func shortHash(_ value: String) -> String { let digest = SHA256.hash(data: Data(value.utf8)) return digest.prefix(6).map { String(format: "%02x", $0) }.joined() } }