|
![]() |
Overclock.net - Overclocking.net > Software, Programming and Coding > Coding and Programming | |
How do I create a logon system in VB.NET 2008
|
||
![]() |
|
|
LinkBack | Thread Tools |
|
|
#1 (permalink) | |||||||||||||
|
My Raison D'Etre
![]()
Join Date: Sep 2007
Location: Stoke on Trent - UK
Posts: 1,728
Rep: 284
![]() ![]() ![]() Unique Rep: 217
Trader Rating: 0
|
I am pondering adding a simple logon screen to an app that I am building for a college project.
I have a simple login window created in VB6 using Random access files and a hashing algorithm (converts to ASCII code, adds then runs a Modulus 197 operation, using that number to place the username and password in a random access flat file), and I was curious about the best way to do it in VB.NET?
__________________
|
|||||||||||||
|
|
|
|
#2 (permalink) | ||||||||||||||
|
4.0 GHz
![]() |
I'm a bit rusty on this, but I believe .NET has an MD5 class...here it is.
Using this class seems to me to be what you're trying to do.(though I admit I'm a bit of a idiot when it comes to stuff like this). I did something like this for a ASP.NET site I did work on. It was simple enough to implement as I recall. I was using a SQL database to store the MD5 hash and using the class methods to read it back when required.
__________________
3DMark06: 19091 - 3DMark Vantage: P15264 - SuperPi: 10.968s Programming Quote of the Day: Bjarne Stroustrup: Quote:
Last edited by dharmaBum : 10-17-09 at 01:26 AM |
||||||||||||||
|
|
|
|
|
#3 (permalink) | ||||||||||||||
|
My Raison D'Etre
![]()
Join Date: Sep 2007
Location: Stoke on Trent - UK
Posts: 1,728
Rep: 284
![]() ![]() ![]() Unique Rep: 217
Trader Rating: 0
|
Quote:
![]() I basically straight-ported the VB6 code I had from college to .NET form and got this: Code:
Public Class frmLive
Dim prfAdm As Profile
Private Sub frmLive_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
btnAcc.Text = "Go!"
btnAcc.BackColor = Color.LimeGreen
btnExt.Text = "Exit"
btnExt.BackColor = Color.Red
lblUsr.Text = "User ID"
lblPsw.Text = "Passcode"
Me.Text = "LiveWire DBSys"
End Sub
Private Sub btnAcc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAcc.Click
Dim passcheck, usercheck As String
Dim MemoryLoc As Integer
usercheck = Trim(txtUsr.Text)
If txtUsr.Text = "admin" Then
If txtPsw.Text = "admin" Then
AddUser()
Else
MsgBox("Wrong Admin Password")
GoTo finish
End If
Else
MemoryLoc = MemoryLocate(Mid(usercheck, 1, 8))
FileOpen(1, "C:\psw.temp", OpenMode.Random, OpenAccess.ReadWrite, , Len(prfAdm))
FileGet(1, prfAdm, MemoryLoc)
passcheck = Trim(prfAdm.Password)
FileClose(1)
If passcheck = txtPsw.Text Then
MsgBox("Welcome to LiveWire!")
Else
MsgBox("Login Failed. Try Again")
End If
End If
finish:
End Sub
Private Function MemoryLocate(ByVal usrname As String)
Dim cconv(0 To usrname.Length - 1) As String
Dim iCount = 1, asctotal As Integer
For iCount = 1 To usrname.Length
cconv(iCount - 1) = Asc(Mid(usrname, iCount, 1))
asctotal += cconv(iCount - 1)
Next
MemoryLocate = asctotal Mod 197
End Function
Private Function AddUser()
Dim username, password As String
Dim MemoryLoc As Integer
username = InputBox("Enter an Appropriate Username (8 Characters Max)")
password = InputBox("Now, Enter a Password to the max of 8 Characters, text and numbers only!")
MemoryLoc = MemoryLocate(username)
FileOpen(1, "C:\psw.temp", OpenMode.Random, OpenAccess.ReadWrite, , Len(prfAdm))
prfAdm.UserName = Trim(username)
prfAdm.Password = Trim(password)
FilePut(1, prfAdm, MemoryLoc)
FileClose(1)
End Function
Private Sub btnExt_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnExt.Click
MsgBox("Thank You For Using LiveWire!")
Me.Close()
End Sub
End Class
__________________
|
||||||||||||||
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
|
|