I would recommend saving the password somewhere in the registry using the SaveSetting command. You can then retrieve the password using the GetSetting command.
The example below saves the password "SecretStuff"
to the registry. The password is then retrieved into the variable strPass in the next line.
I can send you a very nice module for accessing Registry and Ini files if you need more functionality.Code:SaveSetting "MyApp", "Security", "Password", "SecretStuff" strPass = GetSetting("MyApp", "Security", "Password", "")
Keep in mind the following ... If the password is the same for all users store the value under the HKEY_LOCAL_MACHINE area. If the machine uses profiles and each user has their own program specific settings, then store the value under HKEY_CURRENT_USER.
As for encryption... if your users are typical (non-computer geeks), then you can probably get by with just converting the password to its ASCII Numeric value and saving it that way. Example: the string "HELLO" would be represented as: "7269767679". The code below shows an example of this sort of conversion.
To 'decode' the password, just reverse the process by converting each pair of digits in the 'encrypted' password to its true value using the Chr$() function. Example: Chr$(72) will return "H".Code:Dim strPass As String Dim strSave As String Dim intLen As Integer Dim intCnt As Integer strSave = "" strPass = "HELLO" intLen = Len(strPass) For intCnt = 1 To Len(strPass) strSave = strSave & Asc(Mid$(strPass, intCnt, 1)) Next MsgBox strPass & " = " & strSave
This isn't a difficult encryption schema to break, but it might throw off the casual user and is very quick and easy to implement.
Hope this helps.




Reply With Quote