加密在C#中的web.config文件中的连接字符串字符串、文件、web、config

2023-09-02 10:38:05 作者:痞子一生浪

我在的web.config 文件写入我的数据库,用户名和密码的名称作为连接字符串。

我想这个数据进行加密。我该怎么办呢?

 <的ConnectionStrings>
  <添加名称=ISP_ConnectionString的connectionString =数据源= JIGAR;
             初始目录= ISP;集成安全性= TRUE;
             用户ID = jigar;密码= jigar123;
             的providerName =System.Data.SqlClient的/>
< /的ConnectionStrings>
 

解决方案

您可以只使用apnet_regiis工具来做到这一点,只是做

  C: WINDOWS  Microsoft.Net 框架(64)(.NET版本)为aspnet_regiis -pe的ConnectionStrings
 
怎么建web.config文件

针对特定的应用程序,你可以使用应用程序参数-app的应用程序名的,而对于一个特定的网站,你也可以使用该网站的说法上门的网站ID 的

有关详细信息请参阅http://msdn.microsoft.com/en-us/library/dtkwfdky.aspx.

请注意,这适用于只,而不是一个Web应用程序的Windows应用程序。

另外请注意,您必须在命令提示符下使用提升的权限(以管理员身份运行)。

运行

I have written the name of my database, username and password in my web.config file as connection string.

I want to encrypt this data. How can I do it?

<connectionStrings>
  <add name="ISP_ConnectionString" connectionString="Data Source=JIGAR;
             Initial Catalog=ISP;Integrated Security=True;
             User ID=jigar;Password=jigar123;
             providerName="System.Data.SqlClient" />
</connectionStrings>

解决方案

You can just use the apnet_regiis tool to do that ,just do

C:WINDOWSMicrosoft.NetFramework(64)(.Net version)aspnet_regiis -pe "connectionStrings" 

for a specific application you can use the app argument -app application name, and for a specific site you can also use the site argument "-site site id".

For more details see http://msdn.microsoft.com/en-us/library/dtkwfdky.aspx.

Note that this works for a web application only and not for a windows application.

Also note that you have to run it from a command prompt with elevated privileges ("run as administrator").