加密SQL connectionstring c# [英] encrypt SQL connectionstring c#

查看:107
本文介绍了加密SQL connectionstring c#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了连接到sql 2005服务器的c#应用程序(不是asp网页)。在我的源代码中,这个sql-server的密码和userid是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 connectionstring c#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆