Use the command line tool aspnet_regiis.exe
You can also use the aspnet_regiis.exe command line tool to encrypt and decrypt the Web. config file configuration section. You can find this tool in the "% windowsdir % \ Microsoft. NET \ framework \ version" directory. To encrypt a section in the web. config file, you can use the dpapi machine key in this command line tool, as shown below:
Common form of encrypting the Web. config file of a specific website:
Aspnet_regiis.exe-Arg section physical_directory-prov provider |
Or:
Aspnet_regiis.exe-PE section-app virtual_directory-prov provider |
Encrypt the specific instance of the web. config file of a specific website:
Aspnet_regiis.exe-Arg "connectionstrings" "C: \ Inetpub \ wwwroot \ mysite"-prov "dataprotectionconfigurationprovider" |
Or:
Aspnet_regiis.exe-pe "connectionstrings"-app "/mysite"-prov "dataprotectionconfigurationprovider" |
Common form of decrypting the Web. config file of a specific website:
Aspnet_regiis.exe-PDF section physical_directory |
Or:
Aspnet_regiis.exe-Pd section-app virtual_directory |
Decrypts a specific instance of the web. config file of a specific website:
Aspnet_regiis.exe-PDF "connectionstrings" "C: \ Inetpub \ wwwroot \ mysite" |
Or:
You can also specify that aspnet_regiis.exe is used to encrypt/decrypt the machine. config file.
[Prompt] encrypt configuration settings in ASP. NET version 1.x
To protect configuration settings in ASP. NET version 1.x, developers need to encrypt and store sensitive settings in the web server registry, and store them in a "strong" key mode. The configuration file does not store encrypted content (such as ASP. NET 2.0), but only contains a reference to the registry key that stores the encrypted value. For example:
<Identity impersonate = "true" Username = "Registry: HKLM \ SOFTWARE \ my_secure_app \ identity \ aspnet_setreg, username" Password = "Registry: HKLM \ SOFTWARE \ my_secure_app \ identity \ aspnet_setreg, password"/> |
Microsoft released the aspnet_setreg.exe command line tool for developers to encrypt sensitive configuration information and move it to a "strong" Registry portal. Unfortunately, this tool only works for specific configuration settings; in contrast, ASP. NET 2.0 allows encryption of any configuration section.
For an ASP. NET 1.x ApplicationProgramFor more information about using aspnet_setreg.exe, see kb #32990 in msdn. Unfortunately, this command line program can only encrypt predefined sections in configuration settings, and does not allow you to encrypt your own database connection strings and other sensitive information.
Encrypted instance:
C: \ windows \ microsoft. Net \ framework \ v2.0.50727 \ aspnet_regiis-PDF connectionstrings I :\CodeRepository \ wt_projects \ websites \ website