Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Entity Framework and Encrypted Database

I have a column (salary) encrypted in database (MS SQL Server). I am using the entity framework to display/edit the records from the front end. Any idea how to decrypt the column in the front end to show the salary value?

Thanks

like image 676
Tippu Avatar asked Jul 23 '12 13:07

Tippu


People also ask

How do I encrypt data in Entity Framework?

Install "EntityFrameworkCore. EncryptColumn" package to your project. Specify your encryption key in the constructor method of your DbContext class and create a instance from the encryption provider. Yout encryption key must be 128 bit!

Does Entity Framework protect against SQL Injection?

Generally speaking, Entity Framework uses LINQ-to-Entities parametrized queries, and it is not susceptible to traditional SQL Injection attacks. However, Entity Framework does allow for the use of raw SQL queries when working with a relational database, introducing the risk of writing injectable queries.

Is Entity Framework encrypted?

The Entity Framework does not directly handle data encryption. If users access data over a public network, your application should establish an encrypted connection to the data source to increase security.


1 Answers

If you are doing encryption on database level you must use database level for decryption - use ObjectContext.ExecuteStoreQuery<YourEntityType>(...) to load records from database - pass SQL command with correct decryption usage into that method.

like image 190
Ladislav Mrnka Avatar answered Oct 02 '22 07:10

Ladislav Mrnka