Results 1 to 3 of 3

Thread: change password

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Oct 2000
    Posts
    23
    Hi everybody
    I recently created a small vb prog and used the vb login form to open the prog via a password that is predefined in the code. What i'm after is a way of letting the user enter and set their own password. Can anyone help?
    Thanks

  2. #2
    Fanatic Member
    Join Date
    Feb 2000
    Location
    The Netherlands
    Posts
    715
    The best way, is by not hardcoding the password. Store it somewhere in a file.

    To write the password to a file:
    Code:
    Dim Password As String 'the pw
    Password = "top-secret"
    'open the file
    Open "c:\myfile.txt" For Output As #1
        'write it
        Print #1,,Password
        'close the file
    Close #1
    To read the password from a file:
    Code:
    Dim Password As String 'the pw
    'open the file
    Open "c:\myfile.txt" For Input As #1
        'read it
        Line Input #1,,Password
        'close the file
    Close #1
    But now, the password is readable for everybody who opens the file. In a few minutes, I'll post a way to encrypt the password a little.
    Oetje
    [email protected]
    93606776
    Visual Basic 6, Windows 2000

    Never pet a burning dog

  3. #3
    Fanatic Member
    Join Date
    Feb 2000
    Location
    The Netherlands
    Posts
    715
    This code is for encryption/decryption.
    Code:
    Function Crypt(Data As String) As String
        Dim oneByte As String ' a swap variable
        Dim Output As String  ' the output
    
        For i = 1 To Len(Data) 'loop trough all the bytes
            oneByte = Right(Left(Data, i), 1) ' get a byte
            oneByte = Chr((Int(Asc(oneByte)) Xor 152)) ' encrypt the byte
            Output = Output & oneByte ' add it to the output
        Next
        
        Crypt = Output ' return the encrypted or decrypted data
    End Function
    If you give it a string, it will encrypt it. If you give it an encrypted string, it will decrypt it.
    Note that this way of encryption is not very secure. Everybody with some HEX-editor experience can crack it, but the average user can't crack it.
    Oetje
    [email protected]
    93606776
    Visual Basic 6, Windows 2000

    Never pet a burning dog

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