R
Ryan
The following code encrypts the entire section of <appSettings> in app.config.
How do I encrypt only a Key (MyKey) in that section; not the entire section?
e.g.
<add key="MyKey" value="MyKeyValue" />
Private Sub ProtectSection(ByVal sSectionName As [String])
Dim config As Configuration =
ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None)
Dim section As ConfigurationSection = config.GetSection(sSectionName)
If section IsNot Nothing Then
If Not section.IsReadOnly() Then
section.SectionInformation.ProtectSection("RsaProtectedConfigurationProvider")
section.SectionInformation.ForceSave = True
config.Save(ConfigurationSaveMode.Modified)
End If
End If
End Sub
How do I encrypt only a Key (MyKey) in that section; not the entire section?
e.g.
<add key="MyKey" value="MyKeyValue" />
Private Sub ProtectSection(ByVal sSectionName As [String])
Dim config As Configuration =
ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None)
Dim section As ConfigurationSection = config.GetSection(sSectionName)
If section IsNot Nothing Then
If Not section.IsReadOnly() Then
section.SectionInformation.ProtectSection("RsaProtectedConfigurationProvider")
section.SectionInformation.ForceSave = True
config.Save(ConfigurationSaveMode.Modified)
End If
End If
End Sub