DAAB and Cryptography Application Blocks

Posted by Mee_ram under Regular Expressions on 6/17/2011 | Points: 10 | Views : 1826 | Status : [Member] | Replies : 3
We are using Enterprise Library version 5 and maintaining the connectionstring in Web.Config.

I have used the below line in DAL and my application was working fine.
Database db = DatabaseFactory.CreateDatabase("USER-PC");

Now I have encrypted the connectionstring with Cryptography Application Blocks Symmetric Algorithm and the connection string will be like
<add name="USER-PC" connectionString="2D2F447DA70A2CF1E1A61F2475B3D7F67592A67ACF108FFE9E08CFCE3C6463B5C175B6E6A5" providerName="System.Data.SqlClient" />

After this change my application is not working because i don't know how to decrypt the connectionstring with the DatabaseFactory.CreateDatabase("USER-PC").

Please help me to get out of this issue...

Ram


Responses

Posted by: Reena_jainy2k1 on: 6/17/2011 [Member] Starter | Points: 25

Up
0
Down
hi,

try this

try
{
Configuration conf = WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath);
ConfigurationSection confStrSect = conf.GetSection(section);
if (confStrSect != null && confStrSect.SectionInformation.IsProtected)
{
confStrSect.SectionInformation.UnprotectSection();
confg.Save();
}

}
catch (Exception ex)
{

}

Reena Jain
Project Manager

Mee_ram, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Robin_ahuja2008 on: 6/17/2011 [Member] Starter | Points: 25
Posted by: Mee_ram on: 6/17/2011 [Member] Starter | Points: 25

Up
0
Down
Hi Reena,

Thanks and It works. But is it possible to use Cryptography Application Blocks symmetricCryptoProviders of securityCryptographyConfiguration section ?



Ram

Mee_ram, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response