Implementing Encryption/Decryption on a property in my MVC 4 application using Entity Framework 5
Posted on 2014-04-10
I have an MVC 4 web application that uses EF 5. Some of the tables in my application contain data that needs to be encrypted. I am using SQL Server 2005 (soon to be upgraded to 2008).
What is the best way to implement the encryption/decryption?
Do I create a Stored Procedure for encrypting and decrypting the fields in the table and somehow tell EF to use the Stored Procedure when retrieving and setting the value in the fields that require encryption?
Do I create the Encryption / Decryption methods and use them in the get and set operations of the property? If yes, how would I do this? (Assume I have an Encrypt(string) and Decrypt(string) method).
Do I use Data Annotations to indicate the field should be Encrypted and Decrypted? If yes, where would I add the code for Encrypting and Decrypting?
As you can see I really don't have a good idea of where to start so any suggestions are greatly appreciated!