Ibatis. Net website Project Database Connection Encryption

Source: Internet
Author: User

Create a website project in ASP. NET. You cannot embed the sqlmap file into the resource for compilation. Therefore, you cannot encrypt the file. You can use another method to encrypt the file.

1. Create a coding class Library:

 

2. Create the properties. config file:

Code
<? XML version = " 1.0 " Encoding = " UTF-8 "   ?>
< Settings >
<! -- User Application and configured property settings go here. -->
<! -- Example: < Add key = " Settingname " Value = " Settingvalue " />   -->
< Add key = " Connectionstring " Value = " Data Source = dbname; user id = sa; Password = sa "   />
</ Settings >

Right-click the property and embed it into the resource. After compilation, set coding. DLL to the bin folder of the website project.

3. Configure sqlmap:

Code
<? XML version = " 1.0 " Encoding = " UTF-8 " ?>
< Sqlmapconfig xmlns = " Http://ibatis.apache.org/dataMapper " Xmlns: xsi = " Http://www.w3.org/2001/XMLSchema-instance " >
< Properties embedded = " Properties. config, coding " />

< Settings >
< Setting usestatementnamespaces = " True " />
< Setting cachemodelsenabled = " False " />
</ Settings >

<Providers Resource="Providers. config"/>

< Database >
< Provider name = " Oracleclient1.0 " />
< Datasource name = " Documentsystem " Connectionstring = " $ {Connectionstring} " />
<! -- < Datasource name = " Global " Connectionstring = " Data Source =; user id =; Password = " /> -->
</ Database >

Note:

Code
<Properties embedded="Properties. config, coding"/>

Make sure to configure it in this form. Otherwise, after IIS is restarted, the site will fail to find embedded resources and an error will occur. This completes the encryption.

 

 

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.