加密 SQL 连接字符串 C# [英] encrypt SQL connectionstring c#
问题描述
我创建了一个连接到 sql 2005 服务器的 c# 应用程序(不是 asp 网页).在我的源代码中,这个 sql-server 的密码和用户 ID 在 ConnectionString 中被编码为纯文本.
I created an c# application (not asp webpage) which connects to a sql 2005 server. In my sourcecode the password and userid for this sql-server is coded plain text in ConnectionString.
SqlConnection con = new SqlConnection();
con.ConnectionString =
"Data Source=server1;"+
"Initial Catalog=mydatabase;"+
"Integrated Security=no;"+
"User ID=admin;Password=mypassword;";
con.Open();
是否有一种简单的方法可以加密密码或整个连接字符串,而其他反汇编我的工具的人看不到密码?
Is there a easy way to encrypt password or whole connectionstring, that other peoples who disassemble my tool are not able to see the password?
谢谢
推荐答案
您应该将连接字符串存储在配置文件中并加密该部分.请参阅 http://www.4guysfromrolla.com/articles/021506-1.aspx 或 http://msdn.microsoft.com/en-us/library/89211k9b%28VS.80%29.aspx.
You should store your connection string in a config file and encrypt that section. See http://www.4guysfromrolla.com/articles/021506-1.aspx or http://msdn.microsoft.com/en-us/library/89211k9b%28VS.80%29.aspx.
这篇关于加密 SQL 连接字符串 C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!