protected void btnPassWord_Click(object sender, EventArgs e)
{
//加密
Configuration config = WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath);
ConfigurationSection section = config.GetSection("appSetting");
if (section != null && !section.SectionInformation.IsProtected)
{
section.SectionInformation.ProtectSection("RsaProtectedConfigurationProvider");
config.Save();
Response.Write("<script>alert('加密成功');</script>");
}
需要解密文件配置的时候,只需调用SectionInformation类的UnprotectSection方法。