System.Configuration Public Class Form1 Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click 'Encrypt Dim config As System.Configuration.Configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None) Dim configSection As ConfigurationSection configSection = config.AppSettings If Not (configSection Is Nothing) Then If Not (configSection.ElementInformation.IsLocked) Then configSection.SectionInformation.ProtectSection("rsaProtectedConfigurationProvider") configSection.SectionInformation.ForceSave = True config.Save(ConfigurationSaveMode.Full) End If End If MsgBox("Success!") End Sub Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click 'Decrypt Dim config As System.Configuration.Configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None) Dim configSection As ConfigurationSection configSection = config.AppSettings If Not (configSection Is Nothing) Then If Not (configSection.ElementInformation.IsLocked) Then configSection.SectionInformation.UnprotectSection() configSection.SectionInformation.ForceSave = True config.Save(ConfigurationSaveMode.Full) End If End If MsgBox("Success!") End Sub End Class
NetFrameworkConfigurationKey
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)