import { createHash } from "node:crypto";

/**
 * Hash an email for logs (PII minimization).
 * Use a short, stable prefix to correlate events without storing the email itself.
 */
export const hashEmailForLogs = (email: string): string => {
  const normalized = email.trim().toLowerCase();
  return createHash("sha256").update(normalized).digest("hex").slice(0, 12);
};
