6 Replies - 3114 Views - Last Post: 30 December 2010 - 02:00 AM Rate Topic: -----

#1 AX5  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 26-December 10

Add Hash and salt to my project

Posted 26 December 2010 - 11:55 PM

Hi all im creating a simple login / registrate form in visual studio 2008 and i need help if some one can help me inplant Hash and salt to my login and registrate forms, im using mysql to connect to a online mysql server

this is my codes i ahve now

Form 1 - Login
Try
                DB_Connect = New MySqlConnection()
                DB_Connect.ConnectionString = "server=localhost;port=3306; user id=root; password=password; database=vb.net;"
                DB_Connect.Open()
                Dim adapter As New MySqlDataAdapter
                Dim commandstring = "SELECT * FROM user WHERE Username = '" & TextBox1.Text & "' AND Password = '" & TextBox2.Text & "'"
                Dim commander As New MySqlCommand
                commander.Connection = DB_Connect
                commander.CommandText = commandstring
                adapter.SelectCommand = commander
                Dim DataCommand As MySqlDataReader
                DataCommand = commander.ExecuteReader
                If DataCommand.HasRows = 0 Then
                    MsgBox("Error! Wrong login info please check your username or password and try again.", MsgBoxStyle.Information)
                Else
                    Form3.Show()
                    Me.Close()
                End If
                DB_Connect.Close()
            Catch ex As Exception
                MsgBox("Error! Couldnt connect to database please try again. 1", MsgBoxStyle.Critical)
            End Try

Form 2 - Registrate
Try
                                DB_Connect = New MySqlConnection()
                                DB_Connect.ConnectionString = "server=localhost;port=3306; user id=root; password=password; database=vb.net;"
                                DB_Connect.Open()
                                Dim adapter As New MySqlDataAdapter
                                Dim commandstring = "INSERT INTO user (Firstname,Lastname,Username,Password,Created) VALUES('" & TextBox1.Text & "','" & TextBox2.Text & "','" & TextBox3.Text & "','" & TextBox4.Text & "','" & Label7.Text & "')"
                                Dim commander As New MySqlCommand
                                commander.Connection = DB_Connect
                                commander.CommandText = commandstring
                                adapter.SelectCommand = commander
                                Dim DataCommand As MySqlDataReader
                                DataCommand = commander.ExecuteReader
                                MsgBox("Account Created Successfully!" & vbNewLine & "Username: " & TextBox3.Text & vbNewLine & "Password: " & TextBox4.Text, MsgBoxStyle.Exclamation)
                                DB_Connect.Close()
                            Catch ex As Exception
                                MsgBox("Error! Couldnt connect to database please try again. 1", MsgBoxStyle.Critical)
                            End Try


i really need this working, all works but nothing is encrypted

Is This A Good Question/Topic? 0
  • +

Replies To: Add Hash and salt to my project

#2 Curtis Rutland  Icon User is offline

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 4577
  • View blog
  • Posts: 8,019
  • Joined: 08-June 10

Re: Add Hash and salt to my project

Posted 27 December 2010 - 01:33 PM

Here's an example of using a hashing algorithm to hash a password:
http://www.obviex.co...mples/hash.aspx

It starts with C#, but there's a VB.NET example further down the page.

I suggest using the SHA256 or greater algorithm.

You can't just copy/paste this, you'll need to understand it and adapt it to your needs.
Was This Post Helpful? 0
  • +
  • -

#3 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6107
  • View blog
  • Posts: 23,661
  • Joined: 23-August 08

Re: Add Hash and salt to my project

Posted 27 December 2010 - 02:11 PM

There's also this tutorial, again in C#.
Was This Post Helpful? 0
  • +
  • -

#4 AX5  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 26-December 10

Re: Add Hash and salt to my project

Posted 28 December 2010 - 01:23 AM

Does some one have a tutorial how to do this ? i don't have expirens in vb.net connection to mysql
Was This Post Helpful? 0
  • +
  • -

#5 Curtis Rutland  Icon User is offline

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 4577
  • View blog
  • Posts: 8,019
  • Joined: 08-June 10

Re: Add Hash and salt to my project

Posted 28 December 2010 - 07:16 AM

Well, I linked you a tutorial, and you already have code to read and write to MySql. What more do you want? Nobody's going to do it for you.
Was This Post Helpful? 1
  • +
  • -

#6 AX5  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 26-December 10

Re: Add Hash and salt to my project

Posted 29 December 2010 - 11:28 PM

View PostinsertAlias, on 28 December 2010 - 06:16 AM, said:

Well, I linked you a tutorial, and you already have code to read and write to MySql. What more do you want? Nobody's going to do it for you.

i need to know to add the hash and read it on the login and registrations
Was This Post Helpful? 0
  • +
  • -

#7 Curtis Rutland  Icon User is offline

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 4577
  • View blog
  • Posts: 8,019
  • Joined: 08-June 10

Re: Add Hash and salt to my project

Posted 30 December 2010 - 02:00 AM

So...read the tutorial.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1