代码加密解密web.config

Protected Sub btnEncrypt_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnEncrypt.Click Dim config As System.Configuration.Configuration = WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath) Dim section As ConfigurationSection = config.GetSection("connectionStrings") If section IsNot Nothing AndAlso Not section.SectionInformation.IsProtected Then section.SectionInformation.ProtectSection("DataProtectionConfigurationProvider") config.Save() End If End Sub Protected Sub btnDecrypt_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnDecrypt.Click Dim config As System.Configuration.Configuration = WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath) Dim section As ConfigurationSection = config.GetSection("connectionStrings") If section IsNot Nothing AndAlso section.SectionInformation.IsProtected Then section.SectionInformation.UnprotectSection() config.Save() End If End Sub 

你可能感兴趣的:(加密,object,解密)