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.
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();   
}
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With