borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (Drag Frame)Next Topic (USB Storage Device Detection) New Topic New Poll Post Reply
AndreaVB Forum : VB General : Help! This won't work!
Poster Message
Module
Level: Trainee

Registered: 14-04-2007
Posts: 3

icon Help! This won't work!

Hi, I've worked on making part of my USB/SD authentication.
I am about half-way there and I need help making my code work.
here it is:

Dim MD5Gen As MD5

Private Sub Form_Load()
Set MD5Gen = New MD5

' Define all values
Dim UserDrive As String
Dim UserFile As String
Dim UserName As String
Dim DriveSerial As String
Dim UserPassMD5 As String
Dim UserSerialMD5 As String
Dim StoredPassMD5 As String
Dim StoredSerialMD5 As String
Dim DriveSerialMD5 As String

' Set user drive
UserDrive = "J:\"

' Set the user file
UserFile = UserDrive & "User.ini"

' Generate the MD5 for the user drive's real serial
DriveSerialMD5 = LCase(MD5Gen.DigestStrToHexStr(DriveSerialNumber(UserDrive)))

' Reading INI values from user drive
UserName = GetFromINI("User", "Name", "Error", UserFile)
UserPassMD5 = GetFromINI("User", "Code", "Error", UserFile)
UserSerialMD5 = GetFromINI("User", "Serial", "Error", UserFile)

' Reading INI values from local store
StoredPassMD5 = GetFromINI("User", "Code", "Error", "Users\" & UserName & ".ini")
StoredSerialMD5 = GetFromINI("User", "Serial", "Error", "Users\" & UserName & ".ini")

SerialCheck:
' Check if the stored Serial MD5 matches the user drive's real Serial MD5
If StoredSerialMD5 = DriveSerialMD5 Then
    ' The stored serial MD5 matches the real MD5.
    If UserSerialMD5 = DriveSerialMD5 Then
        'The user serial MD5 also matches the real MD5.
        GoTo SerialOK
    Else
        ' The user serial MD5 did not match the real serial MD5
        MsgBox "Your serial numbers could not validate.", vbCritical, "Error"
        Unload Me
    End If
Else
    ' The stored serial MD5 did not match the real serial MD5
    MsgBox "Your serial numbers could not validate.", vbCritical, "Error"
    Unload Me
End If

SerialOK:
PassCheck:
' Check if the stored password MD5 matches the user password MD5
If StoredPassMD5 = UserPassMD5 Then
    ' The stored password MD5 matches the user password MD5
    GoTo PassOK
Else
    ' The stored password MD5 did not match the user password MD5
    MsgBox "Your user codes failed to validate.", vbCritical, "Error"
    Unload Me
End If

End

PassOK:
MsgBox "Yay"
End Sub


Users\Lee.ini looks like this:
[User]
Code=098f6bcd4621d373cade4e832627b4f6
Serial=f73cbef21d187da749b211ae86bad79d


J:\User.ini looks like this:
[User]
Name=Lee
Code=098f6bcd4621d373cade4e832627b4f6
Serial=f73cbef21d187da749b211ae86bad79d


When I run the code I just get told that my serials can't validate and then that my passwords cannot validate.

Why won't it work!?

14-04-2007 at 06:31 PM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
AndreaVB Forum : VB General : Help! This won't work!
Previous Topic (Drag Frame)Next Topic (USB Storage Device Detection) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder