0
public static class CriptoHelper
{
public static string HashMD5(string val)
{
var bytes = Encoding.ASCII.GetBytes(val);
var md5 = MD5.Create();
var hash = md5.ComputeHash(bytes);
var ret = string.Empty;
for (int i = 0; i < hash.Length; i++)
{
ret += hash[i].ToString("x2");
}
return ret;
}
}
public class UsuarioModel
{
public static bool ValidarUsuario(string login, string senha)
{
var ret = false;
using (var conexao = new SqlConnection())
{
conexao.ConnectionString = ConfigurationManager.ConnectionStrings["principal"].ConnectionString;
conexao.Open();
using ( var comando = new SqlCommand())
{
comando.Connection = conexao;
comando.CommandText = "select count(*) from usuario where login =@login and senha=@senha";
comando.Parameters.Add("@login", SqlDbType.VarChar).Value = login;
comando.Parameters.Add("@senha", SqlDbType.VarChar).Value = CriptoHelper.HashMD5(senha);
ret = ((int)comando.ExecuteScalar() > 0);
}
}
return ret;
}
}
I didn’t tell you what the problem is.
– Jéf Bueno
It simply doesn’t Encrypt my password in my database. Doesn’t Login .
– user115154
@Josehenrique If you don’t explain the problem, you can’t help yourself.
– Jéf Bueno