Read SHY520 wrote about the data Access Application Block article, write well, ignoring the point is how to encrypt the database connection string, here I briefly introduce. We know that encrypting the connection string in enterprise Library1.1 requires relying on the cryptography Application Block. NET This feature is already built into the Framework2.0, which is accomplished by some classes under the configuration namespace, and supports two types of encryption:
Dpapiprotectedconfigurationprovider: Using the Windows Data Protection API (DPAPI)
RsaProtectedConfigurationProvider: Using the RSA algorithm
Let's take a look at the specific implementation method, assuming that you already have a configuration file like this:
<?xml version= "1.0" encoding= "Utf-8"?>
<configuration>
<configSections>
<section name= "Dataconfiguration" type= " Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, version=2.0.0.0, culture=neutral, Publickeytoken=null "/>
</configSections>
<dataconfiguration defaultdatabase= "QuickStarts"/>
<connectionStrings>
<add name= "QuickStarts" connectionstring= "database=entlibquickstarts; Server=rj-097;integrated Security=sspi; "
Providername= "System.Data.SqlClient"/>
</connectionStrings>
</configuration>
1. Add a reference to a System.Configuration.dll