namespace HrynCo.NotificationService.Worker.Services.EmailProcessing; public static class RecipientAddressRedactor { public static string Redact(string? address) { if (string.IsNullOrWhiteSpace(address)) return ""; int separator = address.LastIndexOf('@'); if (separator <= 0 || separator == address.Length - 1) return "***"; string local = address[..separator]; string domain = address[(separator + 1)..]; int dot = domain.LastIndexOf('.'); string domainName = dot > 0 ? domain[..dot] : domain; string suffix = dot > 0 ? domain[dot..] : string.Empty; return $"{local[0]}***@{domainName[0]}***{suffix}"; } }