using System; using System.Data; using System.Configuration; using System.Web.Configuration; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; /// <summary> /// Summary description for clsEncrypt /// </summary> public class clsEncrypt { //public clsEncrypt() //{ // // TODO: Add constructor logic here // //} public static object webencrypt() { Configuration config = WebConfigurationManager.OpenWebConfiguration("~"); //' Write the section name of web.config file (connectionStrings) ConfigurationSection configSection = config.GetSection("connectionStrings"); ; //' Check the section of web.config file (connectionStrings) if Protected //' then UnprotectSection (decrypt) the section if (configSection.SectionInformation.IsProtected) { configSection.SectionInformation.UnprotectSection(); config.Save(); } else { //' Check the section of web.config file (connectionStrings) //' if UnprotectSection then //' protect (encrypt) Section the section configSection.SectionInformation.ProtectSection("DataProtectionConfigurationProvider"); config.Save(); } return config; } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)