1

Is there a way to decrypt a column when querying data from a SQL Server (2005/2008) database that has been encrypted using DES via .NET? If so, how? I have the key, but don't know how to use it within the context of a sql server query.

1
  • Was the encryption done in C# code and then written to SQL, or was it done using EncryptByKey? You might consider moving to use the built-in SQL encryption /decryption if the former. Commented Oct 22, 2010 at 18:34

1 Answer 1

3

I would probably consider creating a CLR function in SQL Server to handle this decryption.

You can use this function just like any other UDF within SQL Server to decrypt on demand.

That way, its as simple as using regular .NET C# code to handle it exactly the way you would do it in your application itself.

Sign up to request clarification or add additional context in comments.

2 Comments

Yep, that's how I'd do it. Though, you should carefully consider the use case - is it absolutely necessary to to the decryption in the database, rather than in some service layer? Generally, the fewer times you have to pass the key around, the smaller the vulnerability footprint.
No it's health care related info, one way hashing won't do. I was leaning towards putting a service layer over it anyway, so in that case I don't even need to worry about SQL Server.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.