Reputation: 199
I encrypt my connection string in the web.config with this code in my aspx load.
protected void Page_Load(object sender, EventArgs e)
{
Configuration config = WebConfigurationManager.OpenWebConfiguration("~");
ConnectionStringsSection connSection = (ConnectionStringsSection)config.GetSection("connectionStrings");
connSection.SectionInformation.ProtectSection("DataProtectionConfigurationProvider");
config.Save();
}
I am newbie with c # and for now what I need is decrypt. Any idea how?
I could decrypt only one line using following code.
protected void Page_Load(object sender, EventArgs e)
{
Configuration config = WebConfigurationManager.OpenWebConfiguration("~");
ConnectionStringsSection connSection = (ConnectionStringsSection)config.GetSection("connectionStrings");
//connSection.SectionInformation.ProtectSection("DataProtectionConfigurationProvider");
connSection.SectionInformation.UnprotectSection();
config.Save();
}
Thanks.
Upvotes: 6
Views: 1260
Reputation: 199
I found how to do it here https://msdn.microsoft.com/en-us/library/dtkwfdky(v=vs.100).aspx
I could decrypt by only changing one line of the following code:
protected void Page_Load(object sender, EventArgs e)
{
Configuration config = WebConfigurationManager.OpenWebConfiguration("~");
ConnectionStringsSection connSection = (ConnectionStringsSection)config.GetSection("connectionStrings");
//connSection.SectionInformation.ProtectSection("DataProtectionConfigurationProvider");
connSection.SectionInformation.UnprotectSection();
config.Save();
}
Upvotes: 1