Results 1 to 3 of 3

Thread: Password Problem!

  1. #1

    Thread Starter
    Addicted Member jcouture100's Avatar
    Join Date
    Aug 1999
    Posts
    141
    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.

    Code:
    SaveSetting "MyApp", "Security", "Password", "SecretStuff"
    strPass = GetSetting("MyApp", "Security", "Password", "")
    I can send you a very nice module for accessing Registry and Ini files if you need more functionality.

    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.

    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
    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".

    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.
    JC

  2. #2
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827

    Lightbulb Encryption...

    That's a slightly simpler version of the encryption method I described in another post on this subject today. It's fine as JC said for those kinds of users.

    One thing I would say, though, is that it would be much easier to convert the password the user enters into the number, than the stored number back into the password. This is because an ASCII code can consist of 1, 2 or 3 digits, and knowing whether the number 123123 is the ASCII codes 123 and 123 (two letters), or 12 31 23 (three letters) or any such combination is more comlpicated than it needs to be.

    Comparing the two numbers will give you identical results to comparing the two strings.

    For a slightly more secure method, there was another thread on this subject earlier today.
    Harry.

    "From one thing, know ten thousand things."

  3. #3
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088

    Wink My encryption routine

    Hi, I wrote an encryption function for my chat application (storing username and password). It's only thought for encode and there's no way to get the original word back, but you don't need this if you want to check for passwords...

    Code:
    'Function returns encoded string
    Function eNcode(Text As String) As String
        'eNcode algorithm
        'Copyright © by Fox
        '[email protected]
    
        'No comments in this function, you'll know why ;-)
    
        Dim A As Long
        Dim Code As Long
        Dim Temp As Long
        Dim Result As String
       
        If Text = "" Then
            Encode = ""
            
            Exit Function
        End If
        
        
        For A = 1 To Len(Text)
            Code = Asc(Mid(Text, A, 1))
            Temp = Int(Sin(Code) * Cos(Code * Code) + Cos(Code) * Asc(Mid(Text, 1, 1)) * Sin(Code) * Cos(Code)) - (A + Code)
            Code = Int(Asc(Mid(Text, A, 1)) * A * IIf(Temp = 0, 15, Temp) / (A + 1)) - A
    
            While Code < 0
                Code = Code * Code - A + Sin(A) * A
            Wend
            
            While Code > 255
                Code = Int(Code / 1.577)
            Wend
            
            Result = Result & Chr(Code)
        Next
        
        A = A + Sqr((Code + A) * (Code + A))
        While Len(Result) < MIN_ENCODE_LENGTH
            Code = A
            Temp = Int(Sin(Code) * Cos(Code * Code) + Cos(Code) * A * Sin(Code) * Cos(Code)) - (A + Code)
            Code = Temp + 1
            
            While Code < 0
                Code = Code * Code - A + Sin(A) * A
            Wend
            
            While Code > 255
                Code = Int(Code / 1.577)
            Wend
            
            Result = Result & Chr(Code)
            A = A + 1
        Wend
        
        Encode = Result
    End Function

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width