Using encrypted database join strings in asp.net to ensure data security _ practical Tips

Source: Internet
Author: User
Tags database join connectionstrings

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:)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.