Privacy extension
Protect selected payload values through an explicit conversion boundary and application-owned keys.
Packages: DCoding.Data.DVault.Privacy
On this page
Opt in for selected payloads
DCoding.Data.DVault.Privacy supplies registration, logical encrypted-payload aliases and conversion seams for ordinary EF-mapped payload properties. Installing the package does not encrypt every satellite, redact every read or configure database-at-rest encryption.
Register aliases and key authority
Use one stable logical alias for the marked payload and register it explicitly. The key provider belongs to your application. Conversion requires the narrower IDataVaultEncryptedPayloadKeyProvider contract in addition to the general key-provider seam; configure the mapped property’s converter deliberately.
services.AddDVaultPrivacy(options => options
.RegisterEncryptedPayloadAlias("CustomerProfileEmailEncrypted")
.UseCallerOwnedKeyProvider(keyProvider));Plan the complete data lifecycle
Define key storage, access, rotation and recovery outside the sample code. Decide how protected values are handled in history, exports, logs and backups. Withdrawing a key can prevent decryption; it does not erase rows, clean backups or complete a legal erasure process.
Connect the alias to a mapped property
Registering an alias defines a logical protection boundary. A property must also select its converter. In this mapping excerpt, privacyConfiguration is the injected IDataVaultPrivacyConfiguration and CustomerProfileEmailEncrypted is the same registered alias. The complete repository example applies this to an ordinary EF-mapped demonstration entity; this does not automatically attach encryption to every generated DVault satellite column.
entity.Property(row => row.EmailAddress)
.IsRequired()
.HasConversion(new DataVaultEncryptedPayloadValueConverter(
privacyConfiguration,
"CustomerProfileEmailEncrypted"));Verify storage and round-trip behavior separately
A normal EF read passing through the converter can return plaintext and therefore does not prove that the provider stored protected data. Test the raw stored value separately using a controlled database inspection, clear tracked entities, reload through EF and compare the recovered value. Also exercise missing or wrong key authority and ensure errors, application logs and exports do not accidentally contain the sensitive source value.
- Register a stable alias and a suitable caller-owned key provider.
- Map the selected property to the encrypted-payload converter.
- Inspect the provider value independently of the converter.
- Reload in a fresh tracking context and verify the expected plaintext.
- Test failed key access and your application’s error handling.
Full integration example
The repository’s SQLite quickstart includes a separate, explicit Privacy demonstration with its caller-owned provider and mapped property. Review that complete flow before adapting the excerpt. The library does not provide a compliance guarantee.