我怎么能在我的C#连接字符串隐藏我的密码? [英] How can I hide my password in my C# Connection string?

查看:203
本文介绍了我怎么能在我的C#连接字符串隐藏我的密码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下连接字符串:

Data Source=Paul-HP\MYDB;Initial Catalog=MyMSDBSQL;Persist Security Info=True;User ID=sa;Password=password


本显然可以简单地通过打开app.config文件并查看配置设置查看。

(.net webservice) This can obviously be viewed simply by opening up the app.config file and looking at the configuration settings.

我需要的是一种方法,使黑客无法看到密码。但在同一时间,在另一个数据库部署时离开它可定制的,以便它可以被改变。

What I need is a way to make a hacker unable to see the password. But at the same time, leave it customisable so that it can be changed when deployed on another database.

推荐答案

您的数选项​​ - 我所知道的(按优先顺序)的:

You have a number of options - the ones that I am aware of (in order of preference):


  1. 使用集成(SSPI)安全,你不需要在配置文件密码

  2. 加密连接字符串(见的加密配置信息使用受保护的配置

  3. 单独存储用户名和密码,并使用字符串格式化来构建完整的连接字符串,

因此,例如,在连接字符串可能是这样的:

So for example the connection string might look like this:

Data Source=Paul-HP\MYDB;Initial Catalog=MyMSDBSQL;Persist Security Info=True;User ID={0};Password={1}

我会去选择1,如果多数民众赞成不可能的,那么选项2.我所提到的完整性选项3。

I'd go for option 1, if thats not possible then option 2. I've mentioned option 3 for completeness.

你读过保护连接信息(ADO.NET)

这篇关于我怎么能在我的C#连接字符串隐藏我的密码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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