I use the following code to encrypt and decrypt text strings. I then save them into the registry but you can save it into your DB in a text field. Use your encrypted string against this same function using exactly the same key and it will decrypt it.
Private Function EncDec(byval strString As String) As String
Dim Key As String
Dim Counter1 As Integer
Dim KeyChar As Long
Dim StringChar As Long
Dim CryptedChar As Long
Dim CryptedString As String
Dim Location As Integer
On Error GoTo EncDec_Error
Key = "This is your key. I use a bunch of random characters but you can use whatever you want."
CryptedString = ""
For Counter1 = 1 To Len(strString)
Location = (Counter1 Mod Len(Key)) + 1
KeyChar = Asc(Mid$(Key, Location, 1))
StringChar = Asc(Mid$(strString, Counter1, 1))
CryptedChar = StringChar Xor KeyChar
If CryptedChar = 0 Then
CryptedChar = StringChar
End If
CryptedString = CryptedString & Chr$(CryptedChar)
Next Counter1
EncDec = CryptedString
Exit Function
EncDec_Error:
If Err.Number <> 0 Then
LogError Err.Number, "EncDec_Error - " & Err.Description
End If
End Function