Hi Gijsbert
How "uncrackable" do you want the encryption to be?
MX has given you a subtraction algorithm which, as he says, is simple and easy to crack. A rotation algorithm would be a bit harder, and a real key encryption would present the biggest challenge.
But the thing about passwords is that the encryption does not have to be reversible. You can take a password and feed it through a function that mangles it into a number, which you store. Then, for authentication, you use the same algorithm, and if the two numbers match then you accept the password.
A simple algorithm would, say, take the ANSI code for each character and multiply it by the character position, then add it to a total.
There is no way to take the number and derive from it the original password, although it would be possible, if a hacker knew your algorithm, to make another test string that would end up with the same result.
I guess if that were a concern, then you wouldn't be storing your encryption in a plain text INI file! :-)
--
Graham





by: thenelsonPosted on 2009-11-07 at 13:13:38ID: 25768080
You did not mention the security of encryption you want, Here is a simple substitution scheme. You can change the 7 (and -7) to another number. To use it:
Encrypt:
EncryptedString = EncryptString ("Hello There")
Decrypt:
DecryptedString = EncryptString ("A^eehMa^k^", True)
Function EncryptString(strInput As String, Optional Decrypt As Boolean = False) As String
Dim i As Integer
For i = 1 To Len(strInput)
EncryptString = EncryptString & Chr(Asc(Mid(strInput, i, 1)) + IIf(Decrypt, 7, -7))
Next i
End Function