When we publish the website, encryption web.config, this can effectively guarantee the database user and password security, the steps are as follows:
1. Add encryption Key
Executive: C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis-pc "Hnlaw"-exp
where "Hnlaw" is the key name
2. Add Web.config node
Add between Web.config <configuration></configuration>:
<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. Encryption Web.config
Add a batch file Enweb.bat to the site root directory, as follows:
Copy Code code as follows:
@echo off
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis-pef "System.web/identity" "E:\HS studio\donet2\ Hnlawyer "-prov
"Hnlaw"
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis-pef "connectionstrings" "E:\HS Studio\donet2\hnlawyer "-prov
"Hnlaw"
PAUSE
Register the path and the name above!
Success occurs after running!
4. Decryption
Also add a batch file Deweb.bat to the site root directory, as follows:
Copy Code code as follows:
@echo off
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis-pef "System.web/identity" "E:\HS studio\donet2\ Hnlawyer "
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis-pdf "connectionstrings" "E:\HS Studio\donet2\hnlawyer "
PAUSE
The last thing to note: Find the C:\Documents and Settings\All Users\Application Data\Microsoft\Crypto\RSA\MachineKeys Directory When you're done, and find the build
Key file (can be found by the time), give the Network service Read permission, or it will appear error message from the Provider:the RSA key container could
Not to be opened.
Cannot read
This may appear, if you do not have your own server, do not have permission to modify the MachineKeys directory, do not know there are other solutions, I hope you share the:)