ADVERTENCIA!!! la encriptacion con la funcion md5() es insegura, es mejor usar la encriptacion BCryptPara encriptar contraseñas en tu base de datos lo mas comun es usar la ecriptacion MD5
Codigo C#:
public string GetMD5Hash(string input)
{
MD5CryptoServiceProvider x = new MD5CryptoServiceProvider();
byte[] bs = Encoding.UTF8.GetBytes(input);
bs = x.ComputeHash(bs);
StringBuilder s = new StringBuilder();
foreach (byte b in bs)
{
s.Append(b.ToString("x2").ToLower());
}
string password = s.ToString();
return password;
}
Codigo VB.NET:
Public Function GetMD5Hash(input As String) As String
Dim x As New MD5CryptoServiceProvider()
Byte() bs = Encoding.UTF8.GetBytes(input)
bs = x.ComputeHash(bs)
Dim s As New StringBuilder()
For Each b As Byte in bs
s.Append(b.ToString("x2").ToLower())
Next
Dim password As String = s.ToString()
Return password
End Function
Publicado en tttony.blogspot.com
Publicar un comentario
No hay comentarios.:
Publicar un comentario