maquinadehielo
New member
Hello, i'm trying to decrypt a previously encrypted password from my database on visual studio 2012 (vb.net) but when i do the comparaison between my Textbox(Named TXT_Password) and the decrypted password i'm getting a value named System.Byte[] on the side of the Query, here's the code:
Public Function Return_Pass(ByVal User As String, ByVal Password As String) As Boolean
DB_Comand.Connection = DB_Conexion
DB_Comand.CommandType = CommandType.Text
If User <> "" Then
If Password <> "" Then
DB_Comand.CommandText = "SELECT DES_DECRYPT( PASSWORD ) FROM users WHERE user = '" & User & "'"
DB_DataReader = DB_Comand.ExecuteReader()
DB_DataReader.Read()
If DB_DataReader.HasRows Then
Dim Read_Password As String
Read_Password = DB_DataReader(0).ToString
DB_DataReader.Close() 'HERE'S THE PROBLEM
If Read_Password = Password Then
'Read_Password is getting System.Byte[] Instead of the decrypted password, the Query is 'Okay because when i execute it on MySQL it returns me the decrypted password...
Return_Pass = True
Else
MessageBox.Show("Wrong Password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
Return_Pass = False
End If
Else
MessageBox.Show("Wrong User", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
Return_Pass = False
End If
Else
MessageBox.Show("Empty Password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
Return_Pass = False
End If
Else
MessageBox.Show("Empty User", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
Return_Pass = False
End If
Return Return_Pass
End Function
Sorry for bad english...
Public Function Return_Pass(ByVal User As String, ByVal Password As String) As Boolean
DB_Comand.Connection = DB_Conexion
DB_Comand.CommandType = CommandType.Text
If User <> "" Then
If Password <> "" Then
DB_Comand.CommandText = "SELECT DES_DECRYPT( PASSWORD ) FROM users WHERE user = '" & User & "'"
DB_DataReader = DB_Comand.ExecuteReader()
DB_DataReader.Read()
If DB_DataReader.HasRows Then
Dim Read_Password As String
Read_Password = DB_DataReader(0).ToString
DB_DataReader.Close() 'HERE'S THE PROBLEM
If Read_Password = Password Then
'Read_Password is getting System.Byte[] Instead of the decrypted password, the Query is 'Okay because when i execute it on MySQL it returns me the decrypted password...
Return_Pass = True
Else
MessageBox.Show("Wrong Password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
Return_Pass = False
End If
Else
MessageBox.Show("Wrong User", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
Return_Pass = False
End If
Else
MessageBox.Show("Empty Password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
Return_Pass = False
End If
Else
MessageBox.Show("Empty User", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
Return_Pass = False
End If
Return Return_Pass
End Function
Sorry for bad english...