Results 1 to 7 of 7

Thread: Password Protection

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 1999
    Posts
    8

    Talking

    I have a program that requires the user to log in. I have done several programs like this, but in those there was only a few users, so i hardcoded the passowrd into a variable. Now i have a ton of users and I want to store the passwords in a database. The only problem is that I am not sure how to access the passwords to check for validation. Any help?

    Thanks,
    Steve

  2. #2
    Fanatic Member ExtremePimpness's Avatar
    Join Date
    Jan 2001
    Location
    Indianapolis, Indana - USA
    Posts
    550

    Exclamation The Registry

    You could always encrypt them and storethem in the registry. Using the password as the key to the encryption. and store it with the username as the reg key and the encrypted form of it as the value. so it takes the user name and modifies it with the password to see if it got the same answer it got the first time.

    Example:

    If UCase$(PassText.Text) = DecryptText(GetSetting("MyApp", "Startup", user.text , EncryptText(user.text, pass.text))) Then


    and in a modual put:

    Option Explicit

    #Const CASE_SENSITIVE_PASSWORD = False
    Public Function EncryptText(strText As String, ByVal strPwd As String)
    Dim i As Integer, c As Integer
    Dim strBuff As String

    #If Not CASE_SENSITIVE_PASSWORD Then

    'Convert password to upper case
    'if not case-sensitive
    strPwd = UCase$(strPwd)

    #End If

    'Encrypt string
    If Len(strPwd) Then
    For i = 1 To Len(strText)
    c = Asc(Mid$(strText, i, 1))
    c = c + Asc(Mid$(strPwd, (i Mod Len(strPwd)) + 1, 1))
    strBuff = strBuff & Chr$(c And &HFF)
    Next i
    Else
    strBuff = strText
    End If

    EncryptText = strBuff

    End Function

    'Decrypt text encrypted with EncryptText
    Public Function DecryptText(strText As String, ByVal strPwd As String)
    Dim i As Integer, c As Integer
    Dim strBuff As String

    #If Not CASE_SENSITIVE_PASSWORD Then

    'Convert password to upper case
    'if not case-sensitive
    strPwd = UCase$(strPwd)

    #End If

    'Decrypt string
    If Len(strPwd) Then
    For i = 1 To Len(strText)
    c = Asc(Mid$(strText, i, 1))
    c = c - Asc(Mid$(strPwd, (i Mod Len(strPwd)) + 1, 1))
    strBuff = strBuff & Chr$(c And &HFF)
    Next i
    Else
    strBuff = strText
    End If
    DecryptText = strBuff
    End Function

    To store the passwords use somthing like this:

    SaveSetting "MyApp","StartUp",User.text,encrypttext(uster.text,pass.text)

  3. #3
    Fanatic Member ExtremePimpness's Avatar
    Join Date
    Jan 2001
    Location
    Indianapolis, Indana - USA
    Posts
    550
    ian

  4. #4
    Lively Member
    Join Date
    Jan 2001
    Location
    United Kingdom
    Posts
    86
    yes you could use the registry but i wouldnt suggest it because a) anybody could just delete the string! b) they have the crypted password which Could be unencypt c) a database would be better because only the databse could be passworded so no1 can access it and then it can also be encrypted for increased security. then possible to have a backup of this on seperate partition.
    Kieran Smith
    'Computing' A Level Student

    [email protected]
    Visit my Home Page

    Visual C++ 6.0 Pro
    Visual Basic 6.0 Ent
    SQL, ADO, DAO


    "Computers in the future may weigh no more than 1.5 tons."
    -- Popular Mechanics, forecasting the relentless march of science, 1949

  5. #5
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    If you want security an Access database isn't where you find it...

    Just something to keep in mind when choosing the DBMS you're going to use
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  6. #6
    Lively Member
    Join Date
    Jan 2001
    Location
    United Kingdom
    Posts
    86
    True
    Kieran Smith
    'Computing' A Level Student

    [email protected]
    Visit my Home Page

    Visual C++ 6.0 Pro
    Visual Basic 6.0 Ent
    SQL, ADO, DAO


    "Computers in the future may weigh no more than 1.5 tons."
    -- Popular Mechanics, forecasting the relentless march of science, 1949

  7. #7
    Fanatic Member ExtremePimpness's Avatar
    Join Date
    Jan 2001
    Location
    Indianapolis, Indana - USA
    Posts
    550

    Cool

    They are right those are much more secure. but that was the only code example i had. i hope it helps you.

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