Just took a 'simple' approach with some string manipulations. Won't claim it is absolutely secure but as long as the user cant access the VB code (and thus the 'algorithm' it can be quite a puzzle to get the password. Anyway, for me it is working
Public Function ScramblePassword(strPassword As String)
For IntCounter = 0 To Len(strPassword) - 1
Step1 = Step1 & Chr((Asc(Mid(strPassword, _
Len(strPassword) - IntCounter, 1)) + _
Len(strPassword)) + 15)
Step2 = Step2 & Chr((Asc(Mid(strPassword, _
Len(strPassword) - IntCounter, 1)) + _
(Len(strPassword) - 5) + 10))
Next
For IntCounter = Len(strPassword) To 1 Step -1
Step3 = Step3 & Mid(Step2, IntCounter, 1)
Next
For IntCounter = 1 To Len(strPassword)
Step4 = Step4 & Mid(Step1, IntCounter, 1) & _
Mid(Step3, IntCounter, 1)
Next
ScramblePassword = Left(Step4, Len(strPassword)) & _
Chr(Len(strPassword) + 50) & Right(Step4, Len(Step4) _
- Len(strPassword))
End Function
' Pasword checking Routine :
' The rsPerson!Password is a recordset coming from a table
' in the database where the encrypted passwords are stored.
' The Password is coming from user input in a form
If rsPerson!Password <> ScramblePassword(Password) Then
....
End If
' Use this if nessescary to make the password readable
' again. You do not nessescarily need this in your
' database/code though.
Public Function UnScramblePassword(strPassword As String) Step4 = Left(strPassword, Int(Len(strPassword) / 2)) _
& Right(strPassword, Int(Len(strPassword) / 2))
For IntCounter = 1 To Len(Step4) Step 2
Step1 = Step1 & Mid(Step4, IntCounter, 1)
Next IntCounter
For IntCounter = 0 To Len(Step1) - 1
UnScramblePassword = UnScramblePassword & Chr(Asc(Mid _
(Step1, Len(Step1) - IntCounter, 1)) - Len(Step1) - 15)
Next IntCounter
End Function
"In three words I can sum up everything I've learned about life: it goes on."
- Robert Frost 1874-1963