asp.net2.0 How to encrypt a database join string
In asp.net2.0, when you publish a Web site, you encrypt the web.config, which effectively guarantees the security of your database users and passwords, and the following steps:
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:
@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:
@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 the right to modify the MachineKeys directory, do not know there are other solutions, I hope you share: