Different md5 hash

I’m doing a login window in unity 3d. first I have a textbox to input a user and a password, the password is converted to md5, then is checked in a db, if user and md5 match the entries it returns true, then I load another scene. after a while if a connection fail, it loads again the Login scene but when I input the correct user and password it generates a different hash, what could be the problem, I’m gonna attach my script, any help is appreciated, thanks in advance.

Blockquote

IEnumerator MyAsyncVerifyUserData(string User, string Password)
{
DataTable Login = new DataTable();
OdbcDataAdapter ladpt_adapter = new OdbcDataAdapter();
var HashString = FormsAuthentication.HashPasswordForStoringInConfigFile(Password.Trim(),“MD5”);
print (HashString);
OdbcDBCom = OdbcDBConnx.CreateCommand();
OdbcDBCom.CommandText = “Execute spFindUserData '”+User+“‘,’”+HashString+“'”;
ladpt_adapter.SelectCommand = OdbcDBCom;
ladpt_adapter.Fill(Login);

	if (Login!=null)
	{
		print ("si != null");
		//					print (Login.TableName.ToString());
		print (Login.Columns[0].ColumnName);
		//					Credentials = false;
		if(Login.Columns[0].ColumnName=="intUserId")
		{
			if(Login.Rows.Count>0)
			{
				print ("datos Correctos");							
				yield return Ninja.JumpToUnity;
				Application.LoadLevel("Next Scene");

				yield return Ninja.JumpBack;
			}
			else{
				print ("datos Incorrectos");
			}
		}
		
		
	}
	LoadingEffectC.loading = false;
	yield return null;
}

Blockquote

This is my full code

public class Access3 : MonoBehaviour {

[Header("GUI")]
public GUIStyle Background;
public GUISkin Skin;
public GUIStyle YardPlaning3D;
[Space(10)]
[Header("CONEXION BASE DE DATOS")]
public bool Real = false;
Rect windowRect;
public float differenceW = 1;
string user="";
string passwordToEdit = string.Empty;
char passwordToEdit2;
bool activate = true;
string SP = "";
bool once = true;
bool MandarQuery = false;
bool threadTrue = true;

// bool Actualizando = false;
CreateODBC CScreateODBC;
Task task;
Task taskConnection;

//Methodo conexion
public static OdbcCommand	OdbcDBCom = new OdbcCommand();
public static OdbcConnection OdbcDBConnx = new OdbcConnection();
public static OdbcDataReader reader;// = new OdbcDataReader();

// OdbcDataAdapter ladpt_adapter = new OdbcDataAdapter();

bool Conection=true;
bool Credentials=true;
bool ConectAndCred = false;

// bool ConnectionFail = false;
// string ErrorConexion=“”;

// string Password=“”;

void Awake(){
	Screen.SetResolution(Screen.width,Screen.height,false);
	passwordToEdit=string.Empty;
	this.StartCoroutineAsync(MyAsyncConnection(),out taskConnection);

}

IEnumerator MyAsyncConnection(){
		OdbcDBConnx = new OdbcConnection();
		if (Real){
			OdbcDBConnx.ConnectionString = "Driver={Sybase ASE ODBC Driver};NetworkAddress=xxx.xxxx.xxx.xx;"+
				"Db=xxxxxx;Uid=xxx;Pwd=;xxxx";}
		else{

OdbcDBConnx.ConnectionString = “Driver={Sybase ASE ODBC Driver};NetworkAddress=xxx.xxxx.xxx.xx;”+
“Db=xxxxxx;Uid=xxx;Pwd=;xxxx”;}

		OdbcDBConnx.Open();
		Conection = true;
	yield return null;
}

IEnumerator MyAsyncVerifyUserData(string User, string Password){
	DataTable Login = new DataTable();
	OdbcDataAdapter ladpt_adapter = new OdbcDataAdapter();
	var HashString = FormsAuthentication.HashPasswordForStoringInConfigFile(Password.Trim(),"MD5");
	print (HashString);
	OdbcDBCom = OdbcDBConnx.CreateCommand();
	OdbcDBCom.CommandText = "Execute spFindUserData '"+User+"','"+HashString+"'";
	ladpt_adapter.SelectCommand = OdbcDBCom;
	ladpt_adapter.Fill(Login);

	if (Login!=null)
	{
		print ("si != null");
		//					print (Login.TableName.ToString());
		print (Login.Columns[0].ColumnName);
		//					Credentials = false;
		if(Login.Columns[0].ColumnName=="intUserId")
		{
			if(Login.Rows.Count>0)
			{
				print ("datos Correctos");							
				yield return Ninja.JumpToUnity;
				Application.LoadLevel("Next Scene");

				yield return Ninja.JumpBack;
			}
			else{
				print ("datos Incorrectos");
			}
		}
		
		
	}
	LoadingEffectC.loading = false;
	yield return null;
}

void FixedUpdate() {

	differenceW = (Screen.width/12.8f) / 100f;
}

public  string Md5Sum(string strToEncrypt)
{
	System.Text.UTF8Encoding ue = new System.Text.UTF8Encoding();
	byte[] bytes = ue.GetBytes(strToEncrypt);
	
	// encrypt bytes
	System.Security.Cryptography.MD5CryptoServiceProvider md5 = new System.Security.Cryptography.MD5CryptoServiceProvider();
	byte[] hashBytes = md5.ComputeHash(bytes);
	
	// Convert the encrypted bytes back to a string (base 16)
	string hashString = "";
	
	for (int i = 0; i < hashBytes.Length; i++)
	{
		hashString += System.Convert.ToString(hashBytes*, 16).PadLeft(2, '0');*
  •   }*
    
  •   return hashString.PadLeft(32, '0');*
    
  • }*

  • void OnGUI() {*

  •   if (activate)*
    
  •   {*
    
  •   	GUI.FocusControl("USER");*
    
  •   	activate=!activate;*
    
  •   }*
    
  •   GUI.Box( new Rect (0,0,Screen.width,Screen.height),"",Background);*
    
  •   GUI.skin = Skin;*
    

_ windowRect = new Rect(225differenceW,200differenceW,800differenceW,300differenceW);_

  •   windowRect = GUI.Window( 0, windowRect, DoMyWindow, "Log In");*
    

_ GUI.Box(new Rect(50differenceW,50differenceW,600differenceW,75differenceW),“Yard Planning 3D”,YardPlaning3D);_

  •   GUI.FocusWindow(0);*
    
  • }*
  • void DoMyWindow(int windowID) {*
    _ GUILayout.BeginArea(new Rect(100differenceW,100differenceW,800differenceW,300differenceW));_
  •   GUILayout.BeginHorizontal();*
    

_ GUILayout.Label(“Usuario”,GUILayout.Width(100fdifferenceW));_
_ GUILayout.Space((40f
differenceW));_

  •   GUI.SetNextControlName("USER");*
    

_ user = GUILayout.TextField(user,GUILayout.Width(300f*differenceW));_

  •   GUILayout.EndHorizontal();*
    
  •   GUILayout.BeginVertical();*
    

_ GUILayout.Space((30f*differenceW));_

  •   GUILayout.EndVertical();*
    
  •   GUILayout.BeginHorizontal();*
    
  •   if (Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Return)*
    
  •   {*
    
  •   	if ((passwordToEdit != "") && (user != "") && (LoadingEffectC.loading==false))*
    
  •   	{*
    
  •   		LoadingEffectC.loading = true;*
    
  •   		this.StartCoroutineAsync(MyAsyncVerifyUserData(user,passwordToEdit),out task);*
    
  •   		print(task.State);*
    
  •   	}*
    
  •   }*
    

_ GUILayout.Label(“Password”,GUILayout.Width(120fdifferenceW));_
_ GUILayout.Space((20f
differenceW));_
_ passwordToEdit = GUILayout.PasswordField(passwordToEdit.Trim(),""[0],GUILayout.Width(300fdifferenceW));_

  •   if ((passwordToEdit != "") && (user != "") && (LoadingEffectC.loading==false))*
    
  •   {*
    

_ GUILayout.Space((40*FixRes.x));_

  •   	GUI.SetNextControlName("Log In");*
    
  •   	if (GUILayout.Button(new GUIContent("Log In")))*
    
  •   	{*
    
  •   		if ((passwordToEdit != null) && (user != null))*
    
  •   		{*
    
  •   			LoadingEffectC.loading = true;*
    
  •   			this.StartCoroutineAsync(MyAsyncVerifyUserData(user,passwordToEdit),out task);*
    
  •   			print(task.State);*
    
  •   		}*
    
  •   	}*
    
  •   }*
    
  •   	GUILayout.EndHorizontal();*
    
  •   	GUILayout.BeginHorizontal();*
    

_ GUILayout.Space((220*FixRes.x));_

  •   	if (!Conection)*
    
  •   	{* 
    

_ GUILayout.Label(“Error de Conexion”,GUILayout.Width(300f*differenceW));_

  •   		LoadingEffectC.loading = false;*
    
  •   	}*
    
  •   	if (!Credentials)*
    
  •   	{*
    

_ GUILayout.Label(“Credenciales incorrectas”,GUILayout.Width(300f*differenceW));_

  •   		LoadingEffectC.loading = false;* 
    
  •   	}*
    
  •   	GUILayout.EndHorizontal();*
    
  •   GUILayout.EndArea();*
    
  • }*
    }