如何在SQL Server中的数据进行加密和解密它在.NET应用程序 [英] How to encrypt data in sql server and decrypt it in .net apps
问题描述
我想在SQL Server中一些密码进行加密,并有一个C#应用程序解密。
I want to encrypt some passwords in sql server and have a c# app decrypt them.
很显然,我可以创造一个SP所要求的密码解密,我和它传递给C#应用程序,但这意味着发送明文密码通过网络。
Obviously I can create an SP to decrypt the required password for me and pass this to the c# app, but this means sending the plaintext password over network.
所以,我希望能够加密我在SQL Server的密码(密码,证书等),它可以被传递给我的C#应用程序随后会知道如何解密和使用它。
So I want to be able to encrypt my password in sql server (using passphrase, certificate etc), which can be passed around to my c# apps which will then know how to decrypt it and use it.
我想这一定是可能的(也许使用证书),但真的不知道从哪里开始。
I think this must be possible (maybe using certificates) but not really sure where to start.
可以使用.NET 4.0和SQL Server 2008,如果有新的方法来此。
Can use .net 4 and sql server 2008 if there are new approaches to this.
在此先感谢您的咨询。
推荐答案
您可以创建一个加密/在.NET(2.0)解密组装和部署到SQL Server?这就是我看你怎么能有同样的算法/机制,加密/解密数据的唯一途径。
Could you create an encrypt/decrypt assembly in .NET (2.0) and deploy that to SQL Server? That's the only way I see how you could have the same algorithm/mechanism to encrypt/decrypt your data.
创建.NET程序集的加密/解密,将其部署到SQL Server,用它那里来的数据进行加密,并使用相同的组件/同一个.NET code对数据进行解密在.NET应用程序
Create a .NET assembly with the encryption/decryption, deploy it to SQL Server, use it there to encrypt the data, and use the same assembly / same .NET code to decrypt the data in your .NET app.
这篇关于如何在SQL Server中的数据进行加密和解密它在.NET应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!