Tuesday, June 3, 2008
Creating Encrypted Connection string
Creating Encrypted Connection string
You should always encrypt the connectionStrings section of a configuration file to prevent your database connection strings from being stolen by evil hackers.
aspnet_regiis tool for encryption
The easiest way to encrypt a section in the web configuration file is to use the aspnet_regiis command-line tool.This tool is located at the following path:
C:\WINDOWS \Microsoft.NET \Framework \v2.0.50727 \aspnet_regiis.exe
The following command encrypts the connectionStrings section of a configuration file located in a virtual directory named /MyApp:
aspnet_regiis -pe connectionStrings -app /TestSite
Notice that the -app option is used to specify the application ’s virtual path. You can encrypts a configuration section by using the -pef option.The following command decrypts a configuration file located in a folder named TestSite:
aspnet_regiis -pef connectionStrings c:\TestSite
You can decrypt a configuration section by using the -pdf option.The following command decrypts a configuration file located in a folder named MyWebApp:
aspnet_regiis -pdf connectionStrings c:\Websites \TestSite
You also can decrypt a configuration section by specifying a virtual directory.The follow-ing command uses the -pd option with the -app option:
aspnet_regiis -pd connectionStrings -app /TestSite
Example syntax :
To encrypts a configuration section:
C:\Program Files\Microsoft Visual Studio 9.0\VC>aspnet_regiis -pef connectionStrings c:\Test
Encrypting configuration section...
Succeeded!
To decrypt a configuration section
C:\Program Files\Microsoft Visual Studio 9.0\VC>aspnet_regiis -pdf connectionStrings c:\Test
Decrypting configuration section...
Succeeded!
Creating Encrypted Connection string
Creating Encrypted Connection string
You should always encrypt the connectionStrings section of a configuration file to prevent your database connection strings from being stolen by evil hackers.
aspnet_regiis tool for encryption
The easiest way to encrypt a section in the web configuration file is to use the aspnet_regiis command-line tool.This tool is located at the following path:
C:\WINDOWS \Microsoft.NET \Framework \v2.0.50727 \aspnet_regiis.exe
The following command encrypts the connectionStrings section of a configuration file located in a virtual directory named /MyApp:
aspnet_regiis -pe connectionStrings -app /TestSite
Notice that the -app option is used to specify the application ’s virtual path. You can encrypts a configuration section by using the -pef option.The following command decrypts a configuration file located in a folder named TestSite:
aspnet_regiis -pef connectionStrings c:\TestSite
You can decrypt a configuration section by using the -pdf option.The following command decrypts a configuration file located in a folder named MyWebApp:
aspnet_regiis -pdf connectionStrings c:\Websites \TestSite
You also can decrypt a configuration section by specifying a virtual directory.The follow-ing command uses the -pd option with the -app option:
aspnet_regiis -pd connectionStrings -app /TestSite
Example syntax :
To encrypts a configuration section:
C:\Program Files\Microsoft Visual Studio 9.0\VC>aspnet_regiis -pef connectionStrings c:\Test
Encrypting configuration section...
Succeeded!
To decrypt a configuration section
C:\Program Files\Microsoft Visual Studio 9.0\VC>aspnet_regiis -pdf connectionStrings c:\Test
Decrypting configuration section...
Succeeded!
Comments