Why this matters
LGPD mandates security of personal data; authenticated encryption plus key management reduces breach impact.
For fields like CPF, birth_date, and address, use AES-256-GCM with envelope encryption. Keys must come from a managed KMS; rotate data keys at least annually and store key IDs with the ciphertext.
LGPD mandates security of personal data; authenticated encryption plus key management reduces breach impact.
Side-by-side examples engineers can pattern-match during review.
byte[] cipher = simpleAesEncrypt("secret-key", plaintext);var kmsKeyId = System.getenv("KMS_PRIMARY_KEY");\nSecretKey dataKey = KmsClient.generateDataKey(kmsKeyId);\nCipher c = Cipher.getInstance("AES/GCM/NoPadding");\nc.init(Cipher.ENCRYPT_MODE, dataKey);\nbyte[] ct = c.doFinal(plaintext);\nstore(userId, ct, dataKey.getKeyId());Cipher.getInstance("AES/GCM/NoPadding")Cipher.getInstance("AES/CBC/PKCS5Padding") // no auth tagFrom the same buckets as this rule.
Before handling sensitive personal data (e.g., health, biometric), verify a valid consent record and attach its ID to the processing context. Provide a path to revoke consent and stop further processing.