Skip to content

Column-Level AES-256-GCM Encryption

Sensitive attributes (such as Tax IDs, medical document numbers, and confidential notes) are encrypted at the column level within PostgreSQL using AES-256-GCM.

public class Patient : AggregateRoot, IMustHaveTenant
{
[Encrypted]
public string Cpf { get; private set; } = string.Empty;
}

  1. On SaveChanges() / SaveChangesAsync(): EF Core interceptor detects properties annotated with [Encrypted], serializes and encrypts the plaintext using AES-256-GCM with a tenant-isolated cryptographic key.
  2. On Materialization / Query: Decrypted automatically into C# plaintext in memory before reaching application code.
  3. Database Security: In the event of a raw PostgreSQL database dump or leak, encrypted columns appear as random base64 ciphertext with zero readable data.