K
Kevin Hodgson
I store a users SMTP UserName and Password in a settings class, which is
serialized to an XML Settings File.
I need to encrypt the password string in some manner. Does anyone have any
ideas how to do that and still store it in the XML File?
I was thinking of putting the Encryption/Decryption code in the Get/Set
methods of the SMTPPassword Property.
Sample Code:
Public Sub Persist()
'// Save the Settings object to XML Files
Dim settingsPath As String =
IO.Path.Combine(Application.UserAppDataPath, "settings.xml")
Dim myXMLSerializer As Xml.Serialization.XmlSerializer
Dim settingsFile As IO.StreamWriter
'//Save the settings class
myXMLSerializer = New
Xml.Serialization.XmlSerializer(GetType(Settings))
settingsFile = New IO.StreamWriter(settingsPath)
myXMLSerializer.Serialize(settingsFile, appSettings)
settingsFile.Close()
End Sub
<Serializable()> Public Class Settings
Dim m_SMTPLoginName as String
Dim m_SMTPPassword as String
Public Property SMTPLoginName() as String
Get
Return m_SMTPLoginName
End Get
Set(ByVal Value As String)
m_SMTPLoginName = Value
End Set
End Property
Public Property SMTPPassword() as String
Get
Return m_SMTPPassword
End Get
Set(ByVal Value As String)
m_SMTPPassword = Value
End Set
End Property
End Class
serialized to an XML Settings File.
I need to encrypt the password string in some manner. Does anyone have any
ideas how to do that and still store it in the XML File?
I was thinking of putting the Encryption/Decryption code in the Get/Set
methods of the SMTPPassword Property.
Sample Code:
Public Sub Persist()
'// Save the Settings object to XML Files
Dim settingsPath As String =
IO.Path.Combine(Application.UserAppDataPath, "settings.xml")
Dim myXMLSerializer As Xml.Serialization.XmlSerializer
Dim settingsFile As IO.StreamWriter
'//Save the settings class
myXMLSerializer = New
Xml.Serialization.XmlSerializer(GetType(Settings))
settingsFile = New IO.StreamWriter(settingsPath)
myXMLSerializer.Serialize(settingsFile, appSettings)
settingsFile.Close()
End Sub
<Serializable()> Public Class Settings
Dim m_SMTPLoginName as String
Dim m_SMTPPassword as String
Public Property SMTPLoginName() as String
Get
Return m_SMTPLoginName
End Get
Set(ByVal Value As String)
m_SMTPLoginName = Value
End Set
End Property
Public Property SMTPPassword() as String
Get
Return m_SMTPPassword
End Get
Set(ByVal Value As String)
m_SMTPPassword = Value
End Set
End Property
End Class