Encryption Decryption of web.config sections  

by ne on 2021-09-29 under C#/Php

Many times we need to protect or encrypt our usernames and passwords in web.config.you can do it with the following commands:-

1.Encryption:-for encrypting a section in web.config sections:

write down the following command on run and press enter

for 3.5 framework : C:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis -pef "connectionStrings" "C:\Inetpub\wwwroot\dev"

for 4.0 framework :  C:\WINNT\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis -pef "connectionStrings" "C:\Inetpub\wwwroot\dev"

here "C:\WINNT\Microsoft.NET\Framework" this path can be vary according to your installation, "connectionStrings" this is section which i want to encrypt  and "C:\Inetpub\wwwroot\dev" this is the path of web.config file exists.

2.Decryption :-for Decrypting a section in web.config sections:

write down the following command on run and press enter

for 3.5 framework : C:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis -pdf "connectionStrings" "C:\Inetpub\wwwroot\dev"

for 4.0 framework :  C:\WINNT\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis -pdf "connectionStrings" "C:\Inetpub\wwwroot\dev"

Thanks.