Encrypt a Key in app.config

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
 
M

Mr. Arnold

Ryan said:
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


About the best you could do is come up with some kind of keyboard key
strokes encryption of Shift-key, non Shift-key, Ctrl-Key, non Ctrl-key,
alpha, numeric, and special keys key combination sequence to come up with an
encrypted key for MyKeyValue.

You could get some kind of free Keylogger so you can see the results of the
keystrokes and make it a long sequence. The longer the sequence makes it
harder to crack.

You can use Google, as you might see some free code that will do it for you.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top