Skip to content
bitzorcas
中EN

Reference

Data Masking and Privacy Compliance: IDataMasker Guide

Master BitzOrcas.Modern enterprise data masking. Learn [Masked] contract attributes, dynamic phone/email/card masking algorithms, and GDPR-compliant log redaction.

Last updated

In enterprise software delivery (especially banking, healthcare, and global SaaS), Personally Identifiable Information (PII) protection is a non-negotiable security requirement:

  • Plaintext Logging: Developers casually logging raw phone numbers or national IDs, leaking PII to centralized Elasticsearch/Datadog clusters;
  • Unredacted UI Responses: Unprivileged support operators viewing unmasked customer credit card numbers.

BitzOrcas.Modern includes an embedded IDataMasker engine and [Masked] contract attributes: Dynamically masking sensitive values during JSON serialization, logging, and audit persistence.

Data Masking Lifecycle and PII Defense

1. Domain Aggregate (Full Raw State)

2. Response DTO / Audit Log

3. IDataMasker Engine (Phone: 138****0000 / Email: a***b@corp.com)

4. Structured Logs & Audit Storage (Sanitized)

5. HTTP JSON Response (Safe UI Rendering)


Step 1: Declaring Masked Fields on Contracts

Annotate sensitive fields with [Masked]:

UserProfileDto.cs: Declaring Masked PII Properties
using BitzOrcas.Application.Abstractions.Security;
namespace BitzOrcas.Identity.Contracts.Dtos;
public sealed record UserProfileDto
{
public string UserId { get; init; } = string.Empty;
public string FullName { get; init; } = string.Empty;
// Phone masking: preserves first 3 and last 4 digits (e.g. 138****5678)
[Masked(MaskType.PhoneNumber)]
public string PhoneNumber { get; init; } = string.Empty;
// Email masking: preserves prefix and domain (e.g. a***z@corp.com)
[Masked(MaskType.Email)]
public string Email { get; init; } = string.Empty;
}

Step 2: Sanitizing Audit Entries via IDataMasker

AuditLoggingExtensions.cs: Safe Logging Helper
using BitzOrcas.Application.Abstractions.Security;
public static class AuditLoggingExtensions
{
public static string ToSafeLogString(this string rawPhone, IDataMasker masker)
{
// 1. In-memory masking with minimal heap allocation
var masked = masker.MaskPhoneNumber(rawPhone);
// 2. Return sanitized string safe for centralized logging
return masked;
}
}

Summary

IDataMasker fortifies platform privacy:

  • Declarative Attributes: Clean, readable property annotations;
  • Zero PII Leaks: Sanitized logs, traces, and external APIs by default;
  • Audit-Ready Compliance: Meets strict GDPR and financial security audits out of the box.

100%

Scroll or use controls to zoom · drag when enlarged · double-click for 100% / 200%