In asp. net2.0, web. config is encrypted when a website is published. This effectively ensures the security of database users and passwords. The steps are as follows:
1. Add a key
Run: C: WINDOWSMicrosoft. NETFrameworkv2.0.50727aspnet _ regiis-pc "hnlaw"-exp
"Hnlaw" is the key name.
2. Add a web. config Node
Add:
<ConfigPRotectedData>
<Providers>
<Add keyContainerName = "hnlaw" useMachineContainer = "true" description = "Uses RsaCryptoServiceProvider to encrypt and
Decrypt "name =" hnlaw "type =" System. Configuration. RsaProtectedConfigurationProvider, System. Configuration, Version = 2.0.0.0,
Culture = neutral, PublicKeyToken = b03f5f7f11d50a3a "/>
</Providers>
</ConfigProtectedData>
Note: Here keyContainerName = "hnlaw" and name = "hnlaw" respectively indicate your key name;
3. encrypt web. config
Add a batch file enweb. bat to the root directory of the website. The content is as follows:
@ Echo off
C: WINDOWSMicrosoft. NETFrameworkv2.0.50727aspnet _ regiis-Arg "system. web/identity" "E: HS StudioDonet2Hnlawyer"-prov
"Hnlaw"
C: WINDOWSMicrosoft. NETFrameworkv2.0.50727aspnet _ regiis-Arg "connectionStrings" "E: HS StudioDonet2Hnlawyer"-prov
"Hnlaw"
PAUSE
Register the above path and name!
It appears successfully after running!
4. decryption
Add a batch file deweb. bat to the root directory of the website. The content is as follows:
@ Echo off
C: WINDOWSMicrosoft. NETFrameworkv2.0.50727aspnet _ regiis-Arg "system. web/identity" "E: HS StudioDonet2Hnlawyer"
C: WINDOWSMicrosoft. NETFrameworkv2.0.50727aspnet _ regiis-pdf "connectionStrings" "E: HS StudioDonet2Hnlawyer"
PAUSE
Finally, you should note that after you finish the process, find the C: Documents and SettingsAll Usersapplication DataMicrosoftCryptoRSAMachineKeys directory and find the generated
The key file (which can be searched by Time) can be read by The network service. Otherwise, an Error message from the provider: The RSA key container cocould will appear.
Not be opened.
Unable to read
This may happen. If you do not have your own server and you do not have the permission to modify the MachineKeys directory, you do not know any other solutions. I hope you can share them with us :)