|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hash and salt
I have been playing around with a password hash and salt scheme for my application
But i keep getting an error message when it executes the command object i get the error Unable to cast object of type 'System.byte[]' to type 'system.inconvertible' Any suggestions? [code] Sub CreateAccount(ByVal sender As Object, ByVal e As EventArgs) Dim literror As New LiteralControl '1. Create a connection 'Create connection string to pass database, string holds login information to mySQL, Dim connectionString As String connectionString = "Server=localhost; ;database=ftp1;" 'Builds .net mysql connection and passes connection string into method Dim connection As New MySqlConnection(connectionString) Try '2. Create a command object for the query Dim strSQL As String = _ "INSERT INTO Useraccount(Username,Password) " & _ "VALUES(?Username, ?Password)" Dim objCmd As New MySqlCommand(strSQL, connection) '3. Create parameters Dim paramUsername As MySqlParameter paramUsername = New MySqlParameter("?Username", SqlDbType.VarChar, 25) paramUsername.Value = txtUsername.Text objCmd.Parameters.Add(paramUsername) 'Encrypt the password Dim md5Hasher As New MD5CryptoServiceProvider() Dim hashedBytes As Byte() Dim encoder As New UTF8Encoding() hashedBytes = md5Hasher.ComputeHash(encoder.GetBytes(txtPwd.Text & txtusername.text)) Dim paramPwd As MySqlParameter paramPwd = New MySqlParameter("?Password", SqlDbType.Binary, 16) paramPwd.Value = hashedBytes objCmd.Parameters.Add(paramPwd) 'Insert the records into the database connection.Open() objCmd.ExecuteReader() connection.Close() Catch ex As Exception literror.Text = ex.Message MsgBox(ex.Message) End Try Response.Redirect("userhome.aspx") End Sub [code] |
|
#2
|
||||
|
||||
|
__________________
Come JOIN the party!!! Quote of the Month: Retirement: Because you've given so much of yourself to the company that you don't have anything left we can use. Questions to Ponder: What do you do when you see an endangered animal eating an endangered plant? iif([sarcasm]=true,iif([you have to ask]=true,"didn't work","ha ha ha"),"not sarcasm") copyright© 2008 sbenj69 |
| Viewing: ASP Free Forums > Programming > Visual Basic Programming > Hash and salt |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|