加密SQL ConnectionString的C# [英] encrypt SQL connectionstring c#
问题描述
我创建了连接到SQL 2005服务器的C#应用程序(不ASP网页)。在我的源$ C $ c中的密码和用户ID为这个SQL服务器中的ConnectionString codeD纯文本。
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();
有没有一种简单的方法来加密密码或整个ConnectionString的,那谁拆开我的工具,其他人无法看到密码?
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?
感谢
推荐答案
您应该在连接字符串存储在配置文件,加密部分。见<一href=\"http://www.4guysfromrolla.com/articles/021506-1.aspx\">http://www.4guysfromrolla.com/articles/021506-1.aspx或<一个href=\"http://msdn.microsoft.com/en-us/library/89211k9b%28VS.80%29.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 ConnectionString的C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!