Přidat otázku mezi oblíbenéZasílat nové odpovědi e-mailem [MySQL] Hodnota

Imports MySql.Data.MySqlClient
Imports System.Data
Imports MySql.Data
Imports MySql
Imports System.Data.SqlClient
Imports System.Text
Imports System.Security.Cryptography
Imports FreeLance.pripojeno

Public Class Prihlasit
    Function getMD5Salt(ByVal strToHash As String) As String
        Dim conn As New MySqlConnection()
        Dim cmd As New MySqlCommand()

        conn.ConnectionString = "(tajný)"
        Try
            conn.Open()

        Catch myerror As MySqlException
            MessageBox.Show("Error Connecting to Database: " & myerror.Message)
        End Try

        Dim strText As String = "SELECT password FROM OnlineLance_Players WHERE password='"
        Dim salt As String = "SELECT username FROM OnlineLance_Players Where username='" & login.Text
        Dim penizee As String = "SELECT balance FROM iConomy WHERE username='" & login.Text & "' LIMIT 0,1"
        Dim bytHashedData As Byte()
        Dim encoder As New UTF8Encoding()
        Dim md5Hasher As New MD5CryptoServiceProvider

        Dim passwordBytes As Byte() = encoder.GetBytes(strText)
        Dim saltBytes As Byte() = encoder.GetBytes(salt)

        Dim passwordAndSaltBytes As Byte() = _
        New Byte(passwordBytes.Length + saltBytes.Length - 1) {}

        For i As Integer = 0 To passwordBytes.Length - 1
            passwordAndSaltBytes(i) = passwordBytes(i)
        Next

        For i As Integer = 0 To saltBytes.Length - 1
            passwordAndSaltBytes(i + passwordBytes.Length) = saltBytes(i)
        Next

        bytHashedData = md5Hasher.ComputeHash(passwordAndSaltBytes)

        Dim hashValue As String
        hashValue = Convert.ToBase64String(bytHashedData)

        Return hashValue

    End Function

    Function getMD5Hash(ByVal strToHash As String) As String

        Dim md5Obj As New MD5CryptoServiceProvider

        Dim bytesToHash() As Byte = System.Text.Encoding.ASCII.GetBytes(strToHash)
        bytesToHash = md5Obj.ComputeHash(bytesToHash)
        Dim strResult As String = ""
        For Each b As Byte In bytesToHash
            strResult += b.ToString("x2")
        Next
        Return strResult

    End Function

    Private Sub btn_login_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_login.Click
        Dim conn As MySqlConnection
        conn = New MySqlConnection()
        conn.ConnectionString = "(tajný)"
        Try
            conn.Open()
        Catch myerror As MySqlException
            MessageBox.Show("Chyba při připojování k databázi.: " & myerror.Message)
        End Try
        Dim myAdapter As New MySqlDataAdapter
        Dim salt As String = "SELECT username FROM OnlineLance_Players Where username='" & login.Text
        Dim sqlquery = "SELECT username, password FROM OnlineLance_Players Where username='" & login.Text & "' and password='" & getMD5Hash(password.Text) & "'"
        Dim penizee = "SELECT balance FROM iConomy WHERE username='" & login.Text & "' LIMIT 0,1"
        Dim cmd As New MySqlCommand()
        cmd.Connection = conn
        cmd.CommandText = sqlquery
        myAdapter.SelectCommand = cmd
        Dim myData As MySqlDataReader
        myData = cmd.ExecuteReader()
        If myData.HasRows = 0 Then
            MessageBox.Show("Špatné Údaje !", "Jejda...", MessageBoxButtons.OK, MessageBoxIcon.Error)
        Else
            Dim frm1 = New pripojeno
            pripojeno.wel_money.Text = penizee
            pripojeno.Show()
            Me.Hide()
        End If
    End Sub


End Class

Reakce na odpověď

1 Zadajte svou přezdívku:
2 Napište svou odpověď:
3 Pokud chcete dostat ban, zadejte libovolný text:

Zpět do poradny