Ask a Question related to ASP.NET Security, Design and Development.
-
Rudy #1
MD5 problems
Hello all!
I'm working with the following code..
Function DBAuthenticate(ByVal strUsername As String, ByVal strPassword As
String) As Integer
Dim conLogin As SqlConnection
Dim cmdSelect As SqlCommand
Dim parmReturnValue As SqlParameter
Dim intResult As Integer
conLogin = New
SqlConnection("Server=localhost;UID=**;PWD=**;Data base=sample")
cmdSelect = New SqlCommand("DBAuthenticate", conLogin)
cmdSelect.CommandType = CommandType.StoredProcedure
parmReturnValue = cmdSelect.Parameters.Add("RETURN_VALUE",
SqlDbType.Int)
parmReturnValue.Direction = ParameterDirection.ReturnValue
cmdSelect.Parameters.Add("@username", strUsername)
cmdSelect.Parameters.Add("@password", strPassword)
'Encrypt the password
Dim md5Hasher As New MD5CryptoServiceProvider
Dim hashedDataBytes As Byte
Dim encoder As New UTF8Encoding
hashedDataBytes = md5Hasher.ComputeHash(encoder.GetBytes(strPassword ))
Dim paramPwd As SqlParameter
paramPwd = New SqlParameter("@password", SqlDbType.Binary, 16)
paramPwd.Value = hashedDataBytes
cmdSelect.Parameters.Add(paramPwd)
conLogin.Open()
cmdSelect.ExecuteNonQuery()
intResult = cmdSelect.Parameters("RETURN_VALUE").Value
conLogin.Close()
If intResult < 0 Then
If intResult = -1 Then
lblMessage.Text = "This guest is not registered."
Else
lblMessage.Text = "Sorry, invalid password."
End If
End If
Return intResult
End Function
with this line " hashedDataBytes =
md5Hasher.ComputeHash(encoder.GetBytes(strPassword ))" I am geting the
following error
'Public Overrides Function GetBytes(s As String) As Byte()': Value of
type 'System.Web.UI.WebControls.TextBox' cannot be converted to 'String'.
Any thoughts?
Rudy
Rudy Guest
-
problems with 8.0 Rc4
I've been trying to check that my current application working on postgres 7.4 will work with 8.0. I've not checked the application yet but I'm... -
problems with preLoadNetThing and fileName (was problems with preLoadNetThing and importFileInto)
You don't want to leave the QT member in your cast when you publish your movie - it's not really there, it's linked. When you run the movie it will... -
IE6 problems
I have a login script to a website where a user logs in through a standard webform with a username and password that needs to be validated. My... -
I having problems with IIS
I just tried to view a page that I had earlier on my own personal web site and was not able to view it. I then tried just plain old localhost and... -
Why am I Having Problems ?
On 8/2/03 1:08 PM, in article 6TUWa.216121$o86.33889@news1.central.cox.net, "Spam@markris.com" <Spam@markris.com> wrote: A Relationship requires... -
Jason Brown [MSFT] #2
Re: MD5 problems
try
hashedDataBytes =
md5Hasher.ComputeHash(encoder.GetBytes(strPassword .ToString()))
I'm assuming your textbox is cdalled 'strpassword'?
--
Jason Brown
Microsoft GTSC, IIS
This posting is provided "AS IS" with no warranties, and confers no rights.
"Rudy" <Rudy@discussions.microsoft.com> wrote in message
news:B9CB5253-5CA6-42F3-8844-818FCCE5D2E7@microsoft.com...> Hello all!
>
> I'm working with the following code..
>
> Function DBAuthenticate(ByVal strUsername As String, ByVal strPassword As
> String) As Integer
> Dim conLogin As SqlConnection
> Dim cmdSelect As SqlCommand
> Dim parmReturnValue As SqlParameter
> Dim intResult As Integer
>
> conLogin = New
> SqlConnection("Server=localhost;UID=**;PWD=**;Data base=sample")
> cmdSelect = New SqlCommand("DBAuthenticate", conLogin)
> cmdSelect.CommandType = CommandType.StoredProcedure
> parmReturnValue = cmdSelect.Parameters.Add("RETURN_VALUE",
> SqlDbType.Int)
> parmReturnValue.Direction = ParameterDirection.ReturnValue
> cmdSelect.Parameters.Add("@username", strUsername)
> cmdSelect.Parameters.Add("@password", strPassword)
> 'Encrypt the password
> Dim md5Hasher As New MD5CryptoServiceProvider
>
> Dim hashedDataBytes As Byte
> Dim encoder As New UTF8Encoding
>
> hashedDataBytes =
> md5Hasher.ComputeHash(encoder.GetBytes(strPassword ))
>
> Dim paramPwd As SqlParameter
> paramPwd = New SqlParameter("@password", SqlDbType.Binary, 16)
> paramPwd.Value = hashedDataBytes
> cmdSelect.Parameters.Add(paramPwd)
>
> conLogin.Open()
> cmdSelect.ExecuteNonQuery()
> intResult = cmdSelect.Parameters("RETURN_VALUE").Value
> conLogin.Close()
> If intResult < 0 Then
> If intResult = -1 Then
> lblMessage.Text = "This guest is not registered."
> Else
> lblMessage.Text = "Sorry, invalid password."
>
> End If
> End If
> Return intResult
>
> End Function
>
> with this line " hashedDataBytes =
> md5Hasher.ComputeHash(encoder.GetBytes(strPassword ))" I am geting the
> following error
>
> 'Public Overrides Function GetBytes(s As String) As Byte()': Value of
> type 'System.Web.UI.WebControls.TextBox' cannot be converted to 'String'.
>
>
> Any thoughts?
>
> Rudy
>
Jason Brown [MSFT] Guest
-
Rudy #3
Re: MD5 problems
Hi Jason!
Actually, my textbox is "txtnicPass.text"
hashedDataBytes = md5Hasher.ComputeHash(encoder.GetBytes(txtnicPass. Text))
Sorry, I forgot to change to my original code, and problem. So with this, I
get this error
" Value of type '1-dimensional array of Byte' cannot be converted to 'Byte'."
Any ideas?
Thanks!
Rudy
"Jason Brown [MSFT]" wrote:
> try
>
> hashedDataBytes =
> md5Hasher.ComputeHash(encoder.GetBytes(strPassword .ToString()))
>
> I'm assuming your textbox is cdalled 'strpassword'?
>
>
> --
> Jason Brown
> Microsoft GTSC, IIS
>
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
> "Rudy" <Rudy@discussions.microsoft.com> wrote in message
> news:B9CB5253-5CA6-42F3-8844-818FCCE5D2E7@microsoft.com...>> > Hello all!
> >
> > I'm working with the following code..
> >
> > Function DBAuthenticate(ByVal strUsername As String, ByVal strPassword As
> > String) As Integer
> > Dim conLogin As SqlConnection
> > Dim cmdSelect As SqlCommand
> > Dim parmReturnValue As SqlParameter
> > Dim intResult As Integer
> >
> > conLogin = New
> > SqlConnection("Server=localhost;UID=**;PWD=**;Data base=sample")
> > cmdSelect = New SqlCommand("DBAuthenticate", conLogin)
> > cmdSelect.CommandType = CommandType.StoredProcedure
> > parmReturnValue = cmdSelect.Parameters.Add("RETURN_VALUE",
> > SqlDbType.Int)
> > parmReturnValue.Direction = ParameterDirection.ReturnValue
> > cmdSelect.Parameters.Add("@username", strUsername)
> > cmdSelect.Parameters.Add("@password", strPassword)
> > 'Encrypt the password
> > Dim md5Hasher As New MD5CryptoServiceProvider
> >
> > Dim hashedDataBytes As Byte
> > Dim encoder As New UTF8Encoding
> >
> > hashedDataBytes =
> > md5Hasher.ComputeHash(encoder.GetBytes(strPassword ))
> >
> > Dim paramPwd As SqlParameter
> > paramPwd = New SqlParameter("@password", SqlDbType.Binary, 16)
> > paramPwd.Value = hashedDataBytes
> > cmdSelect.Parameters.Add(paramPwd)
> >
> > conLogin.Open()
> > cmdSelect.ExecuteNonQuery()
> > intResult = cmdSelect.Parameters("RETURN_VALUE").Value
> > conLogin.Close()
> > If intResult < 0 Then
> > If intResult = -1 Then
> > lblMessage.Text = "This guest is not registered."
> > Else
> > lblMessage.Text = "Sorry, invalid password."
> >
> > End If
> > End If
> > Return intResult
> >
> > End Function
> >
> > with this line " hashedDataBytes =
> > md5Hasher.ComputeHash(encoder.GetBytes(strPassword ))" I am geting the
> > following error
> >
> > 'Public Overrides Function GetBytes(s As String) As Byte()': Value of
> > type 'System.Web.UI.WebControls.TextBox' cannot be converted to 'String'.
> >
> >
> > Any thoughts?
> >
> > Rudy
> >
>
>Rudy Guest



Reply With Quote

