Files
Sprachmittler/Packages/SprachmittlerKit/Sources/SprachmittlerCore/LogRedaction.swift
T
schihei 7ca5c710ec feat(m0): complete scaffold, logging and signature checks (T0.2-T0.6)
Add os.Logger categories, OSSignposter wrapper and shortHash helper; enforce exact Debug/Release/install signatures; lint tests; update M0 docs and progress.
2026-11-26 12:33:51 +01:00

16 lines
677 B
Swift

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()
}
}