Encrypting the connection string in web.config file in C#

前端 未结 2 1589
北荒
北荒 2020-12-16 12:16

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?<

2条回答
  •  半阙折子戏
    2020-12-16 12:31

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

    C:\WINDOWS\Microsoft.Net\Framework(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").

提交回复
热议问题