|
hi,,I developed website(asp.net vb)..on the login page the user have to enter not the whole passworad the page will ask him
to enter just 4 digits of his passworad and that number appear
randomly.my problem now I dont know how the compare will work between the passworad which he entered with the passworad which is saved on database.
|
|
|
|
|
You'll need to use string functions, such as MID, LEFT, SUBSTRING, etc either in SQL or in C# and compare the same characters.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
But each random number is equal the index of the passworad which the password will be store in one string so, it should be compare one by one !!!!
Also the random numbers it repeated it shuld be not and I found by swap to be not repeated but is reapate.??
|
|
|
|
|
I'm sorry, but I can't understand this at all.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
how are you storing the password, as a hash?, encrypted?
|
|
|
|
|
Yes,it was encrypted by RSA
|
|
|
|
|
Sounds like you've been painted into a corner on this one.
You would probably have to decrypt the password, take the first 4 chars, and do a string.compare against the 2 values.
|
|
|
|
|
Just off the top of my head, I write in vb, not that quick in c sharp. But I put about 10 minutes into it just to test 1 char. I would have to come back to convert the program to test char positions 2-4-6-7. I'm a little fuzzy on integer array, in which I can loop the Integer array of p1 to test 2-4-6-7 in the same loop, and produce a exit code such as 0 for success or 1 for failure.
[edit]
If I used the integer array of p1 for looping, I could just match the int value to the char position much faster. But that's my weakness.
Dim p1() as Integer = 2467
Anyways this is just a starter thought
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
Dim uPassword() As Char = "fortune"
Dim p1 As Integer = 2
Dim p1c As Char = "r"
Dim pMatch As Integer = 1
Dim input(uPassword.Length - 1) As Char
For i As Integer = 0 To uPassword.Length - 1
'Just building the password char array to validate the thought
input(i) = uPassword(i)
If (p1 = i) Then
If (uPassword(i) = p1c) Then
pMatch = 0
End If
End If
Next
Response.Write("<span style=""color: black;"">" & input & "</span>" & _
"<br /><span style=""color: black;"">" & pMatch.ToString & "</span>")
End Sub
|
|
|
|
|
So what did you end up doing?, let's see this amazing function because I must admit it's on the advance level, since you have gone beyond the string and into chars.
|
|
|
|
|
First on Page_Load the 4 random numbers are generated and store it in one array which
is public shared , then on login buttom i retreve password based on user name to take one record
and store that passwoard on variable (passdbo) then I do like this
x1 = (arrNumber(0) - 1)
a1 = passdbo.Chars(x1)
x2 = (arrNumber(1) - 1)
a2 = passdbo.Chars(x2)
x3 = (arrNumber(2) - 1)
a3 = passdbo.Chars(x3)
x4 = (arrNumber(3) - 1)
a4 = passdbo.Chars(x4)
passdb = Val(a1 + a2 + a3 + a4)
pass = Val(TextBox2.Text)
If String.Compare(passdb, pass) Then
Response.Redirect("student.aspx")
Else
MsgBox("Invalid Username OR Password ")
End If
|
|
|
|