Encrypting And Decrypting Web.Config

We can encrypt each section of the web.config using the encryption provided by aspnet_regiis.exe.

Encrypt Connection String

C:\WebPortal>aspnet_regiis.exe -pef connectionStrings c:\WebPortal-prov
"RsaProtectedConfigurationProvider"


Encrypting configuration section.

Succeeded!

Here the -pe switch specifies the configuration section "connectionStrings" to encrypt.

C:\WebPortal>aspnet_regiis.exe -pdf connectionStrings c:\WebPortal

Decrypting configuration section.

Succeeded!

Here the -pef switch specifies the configuration section to encrypt and allows you to supply the physical directory path for your configuration file.

Encrypt AppSettings

C:\WebPortal>aspnet_regiis.exe -pef appSettings c:\WebPortal-prov "RsaProtectedConfigurationProvider"

Encrypting configuration section.

Succeeded!

Here the -prov switch specifies the provider name.

C:\WebPortal>aspnet_regiis.exe -pdf appSettings c:\WebPortal

Decrypting configuration section.

Succeeded!

Ebook Download
View all
Learn
View all