I have a windows aplication that woks whit the asp.net tables in database, so i have a login form in my app.
You can check the user name in the tables, because its not encrypted, but the passwor?
Easy.. Encrypt the users password and compare it whit the password asociated whit the user in the database.
--------------------------------------------------------------------------------
strNombre = Trim(Me.txtUsuario.Text)
strClave = Trim(Me.txtContraseña.Text)
strcon = "SELECT * " & _
"FROM aspnet_Users a " & _
"INNER JOIN aspnet_membership b ON b.userid = a.userid " & _
"WHERE a.UserName= '" & strNombre & "'"
ds = gfEjecutar(strcon)
'ds = dataset returning the query result
If ds.Tables(0).Rows.Count > 0 Then
dr = ds.Tables(0).Rows(0)
'dr = datarow
Dim strPassword As String
Dim strSalt As String
strSalt = dr("PasswordSalt")
strPassword = EncodePassword(strClave, strsalt)
If dr("Password") Like strPassword Then
gstrUserName = strNombre
Dim frm As New frmExpedicion
frm.Show()
Me.Hide()
Else
MsgBox("Contraseña incorrecta", MsgBoxStyle.Information, Me.Text)
Exit Sub
End If
Else
MsgBox("Usuario no registrado", MsgBoxStyle.Information, Me.Text)
Me.txtUsuario.Text = ""
Me.txtUsuario.Focus()
Exit Sub
End If
this is the function who encrypt the password like asp.net
Friend Function EncodePassword(ByVal pass As String, ByVal salt As String) As String
Dim buffer1 As Byte() = Encoding.Unicode.GetBytes(pass)
Dim buffer2 As Byte() = Convert.FromBase64String(salt)
Dim buffer3 As Byte() = New Byte((buffer2.Length + buffer1.Length) - 1) {}
Dim buffer4 As Byte() = Nothing
Buffer.BlockCopy(buffer2, 0, buffer3, 0, buffer2.Length)
Buffer.BlockCopy(buffer1, 0, buffer3, buffer2.Length, buffer1.Length)
Dim algorithm1 As System.Security.Cryptography.HashAlgorithm = System.Security.Cryptography.HashAlgorithm.Create(Membership.HashAlgorithmType)
If algorithm1 Is Nothing Then
Throw New Exception("Error creating hash algorithm type: SHA1(")
End If
buffer4 = algorithm1.ComputeHash(buffer3)
Return Convert.ToBase64String(buffer4)
End Function
if anybody needs more help... you know feel free to see my space Sebastian Greco