|
-
May 11th, 2006, 12:19 AM
#1
Thread Starter
New Member
enrypt decrypt
Hello VB people
could you help me solve my problem in decrypting and encrypting. Im using Visual Basic 6.0 as front end and MS ACCESS 2003 as my back end.
My problem is even i enter the correct user name and password still the message box is "Unauthorized user"
Here is my code to check.
Private Sub Command1_Click()
Static counter As Integer
Set userdb = OpenDatabase(App.Path & "\finance.mdb")
Set usertb = userdb.OpenRecordset("Login", dbOpenTable)
usertb.Index = "Uname"
usertb.Seek "=", Text1.Text
If usertb.NoMatch Then
MsgBox "User ID is not valid", vbInformation
x.Text = Val(x.Text) + 1
Text1.Text = ""
Text2.Text = ""
Text1.SetFocus
If Val(x.Text) > 3 Then
MsgBox "Unauthorized user"
Unload Me
Exit Sub
End If
Else
If Decrypt(usertb.Fields("Pass")) = Text2.Text Then
VarTest = 0
Command1.Visible = False
Command2.Visible = False
MsgBox "user access granted"
uservar = Text1.Text
usertb.Close
userdb.Close
MAIN.Show
Unload Me
Else
MsgBox ("Wrong password")
x.Text = Val(x.Text) + 1
Text1.Text = ""
Text2.Text = ""
Text1.SetFocus
If Val(x.Text) > 3 Then
MsgBox "**** ka!", vbInformation
Unload Me
Exit Sub
End If
End If
End If
End Sub
Module:
Global VarTest As String
Global CatchLogger As String
Global LoggeR As String
Function Encrypt(InputTxt As String)
For ctr = 1 To Len(InputTxt)
Encrypt = Encrypt + Chr(Asc(Mid(InputTxt, ctr, 1)) + 69)
Next ctr
End Function
Function Decrypt(InputTxt As String)
For ctr = 1 To Len(InputTxt)
Decrypt = Decrypt + Chr(Asc(Mid(InputTxt, ctr, 1)) - 69)
Next ctr
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|