Add os.Logger categories, OSSignposter wrapper and shortHash helper; enforce exact Debug/Release/install signatures; lint tests; update M0 docs and progress.
16 lines
677 B
Swift
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()
|
|
}
|
|
}
|