Encrypt/Decrypt Web.config Sections

Encryption of sections in my web.config file is a task I am constantly looking up on the Internet, so I thought I’d blog it here.

-- Generic form for encrypting the Web.config file for a particular website...
aspnet_regiis.exe -pef section physical_directory –prov provider
   -- or --
aspnet_regiis.exe -pe section -app virtual_directory –prov provider
-- Concrete example of encrypting the Web.config file for a particular website...
aspnet_regiis.exe -pef "connectionStrings" "C:InetpubwwwrootMySite" –prov "DataProtectionConfigurationProvider"
   -- or --
aspnet_regiis.exe -pe "connectionStrings" -app "/MySite" –prov "DataProtectionConfigurationProvider"
-- Generic form for decrypting the Web.config file for a particular website...
aspnet_regiis.exe -pdf section physical_directory
   -- or --
aspnet_regiis.exe -pd section -app virtual_directory
-- Concrete example of decrypting the Web.config file for a particular website...
aspnet_regiis.exe -pdf "connectionStrings" "C:InetpubwwwrootMySite"
   -- or --
aspnet_regiis.exe -pd "connectionStrings" -app "/MySite"

Thanks to Scott Mitchell for the source of information.

One thought on “Encrypt/Decrypt Web.config Sections

  1. http://

    I constantly look up encryption for app.config, but I still have no luck, except for an article from CodeProject to use installer to encrypt.

Comments are closed.