Pet Shop 4.0 – Encrypt WebConfig section and Decrypt WebConfig Section “ConnectionString”

As we know, ConnectionString contains User Name and Password.
for security reason, Connection String needed to be Encrypted.

Here is sample code in Pet Shop.

EncryptWebConfig.bat
@echo off
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe -pef “connectionStrings” “C:\Program Files\Microsoft\.NET Pet Shop 4.0\Web”
PAUSE

DecryptWebConfig.bat
@echo off
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe -pdf “connectionStrings” “C:\Program Files\Microsoft\.NET Pet Shop 4.0\Web”
PAUSE

run EncryptWebConfig.bat the section will be like following:

1
2
3
4
5
  <connectionStrings configProtectionProvider="RsaProtectedConfigurationProvider">
    <EncryptedData Type="http://www.w3.org/2001/04/xmlenc#Element"
     ....         
    </EncryptedData>
  </connectionStrings>

run DecryptWebConfig.bat web.config will be normally displayed.

This entry was posted in Uncategorized. Bookmark the permalink.