Can I encrypt value in C# and use that with SQL Server 2005 symmetric encryption?

Posted by Robert Byrne on Stack Overflow See other posts from Stack Overflow or by Robert Byrne
Published on 2010-06-11T12:05:45Z Indexed on 2010/06/12 11:22 UTC
Read the original article Hit count: 272

To be more specific, if I create a symmetric key with a specific KEY_SOURCE and ALGORITHM (as described here), is there any way that I can set up the same key and algorithm in C# so that I can encrypt data in code, but have that data decrypted by the symmetric key in Sql Server?

From the research I've done so far, it seems that the IDENTITY_VALUE for the key is also baked into the cypher text, making things even more complex.

I'm thinking about just trying all the various ways I can think of, ie hashing the KEY_SOURCE using different hash algorithms for a key and trying different ways of encrypting the plain text until I get something that works. Or is that just futile?

Has anyone else done this, any pointers?

UPDATE

Just to clarify, I want to use NHibernate on the client side, but theres a bunch of stored procedures on the database side that still perform decryption.

© Stack Overflow or respective owner

Related posts about c#

Related posts about sql-server