views:

122

answers:

3

Need to store the username and password for an outside application inside of a windows forms vb.net app. For initial testing, I just set the settings type to "Text", but want more security.

There are System.Security and Encryption types available, but not sure where to begin. Any suggestions on how to Add, Update, and Delete the values is appreciated. Seems to be much more involved than the plain text.

Although I want some level of security, this is not for any type of financial or medical application.

EDIT: Code Error System.Configuration.Configuration Type is not defined.

Dim config As System.Configuration.Configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None)
Dim configSection ConfigurationSection
configSection = config.ConnectionStrings
If Not (configSection Is Nothing) Then
    If Not (configSection.ElementInformation.IsLocked) Then
        configSection.SectionInformation.ProtectSection ("DataProtectionConfigurationProvider")
        configSection.SectionInformation.ForceSave = True
        config.Save(ConfigurationSaveMode.Full)
    End If
End If
A: 

See this previously asked question:

http://stackoverflow.com/questions/1392876/encrypting-passwords-in-winforms-app-config-net

It's pretty similar to yours and the answer applies as well.

David Stratton
No answers were accepted. The VB.NET code sample given are not working (see my code update).
Jeff O
A: 

.NET Framework Developer's Guide: Cryptographic services

ikhaldeev
A: 

Decided to stick with the string type and just encrypt the values being saved. The answer to this was helpful: http://stackoverflow.com/questions/1629828/how-to-encrypt-a-string-in-net

Jeff O