Eastrall / EntityFrameworkCore.DataEncryption

A plugin for Microsoft.EntityFrameworkCore to add support of encrypted fields using built-in or custom encryption providers.
MIT License
326 stars 54 forks source link

How To Decrypt the Data at the Database level using the Same Key used in EF #64

Open uppercuut opened 4 months ago

mmhafner commented 1 month ago

Good question

Xor-el commented 1 month ago

if you wish to decrypt data already encrypted in the DB, you can try the approach suggested here. I have no idea if it would work though.

However, if you need EFCore to do the decryption on the DB level, that won't happen as the encryption/decryption with this library works as a value converter and is done at the EFCore layer, not the DB one. What this means is that filtering on an encrypted column using EFCore will always pull the data to the client side before decrypting and then filtering.

uppercuut commented 3 weeks ago

this a huge limitation, which need to taken with a different approach ,

Say I have a complex query that needs to be used where inside of the SQL this wont work by the current state.

Xor-el commented 3 weeks ago

@uppercuut to achieve what you want (decrypting on the database level) is possible albeit with some extra work on your end. You need to write a user-defined function that handles the decryption on the db level.

You can read more about it here

User-defined function mapping