Database connection string encryption and decryption in Web. cofig

Source: Internet
Author: User

I,Aspnet_regiis.exeFile Path:

C: \ windows \ Microsoft. NET \ framework \ v2.0.50727

 

II, UtilizationDoSCommand to create an exportedRSAKey container, namedKey :
Aspnet_regiis-PC"Key"-Exp 

 

III,Web. configConfiguring

<! --Encrypts database connection strings-->

<Configprotecteddata>

<Providers>

<Clear/>

< Add Name = " keyprovider " type =" system. configuration. rsaprotectedconfigurationprovider, system. configuration, version = 2.0.0.0, culture = neutral, publickeytoken = b03f5f7f11d50a3a, processorarchitecture = msil " keycontainername =" key " usemachinecontainer =" true "/>

</Providers>

</Configprotecteddata>

connectionstrings >

Add name = " connectionstr " connectionstring =" Data Source =. \ sqlexpress; initial catalog = membershiptest; Integrated Security = true "

Providername="System. Data. sqlclient"/>

</Connectionstrings>

Note:KeyIs the secret container name created in step 2

 

Note:The above configuration is inConfigurationAnd make sure thatConfigurationUnder the nodeXmlnsThe property has the following values:

<Configuration xmlns = "http://schemas.microsoft.com/.NetConfiguration/v2.0">

 

Iv. ExploitationDoSCommand pairWeb. configFile encryption:

Aspnet_regiis-Arg "connectionstrings" "D: \ test \ membership1"-prov "keyprovider"

Note:

Connectionstrings:Web. configNode name,

D: \ test \ membership1:Web. configPhysical path of the file (excluding the file name)

Keyprovider:Web. configName of the encryption node added to the file

 

V. ExploitationDoSCommand pairWeb. configFile decryption:

aspnet_regiis-PDF" connectionstrings "" D: \ test \ membership1 "

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.