martes, 26 de febrero de 2008

Método para encriptar a MD5

public string md5(string strPlainText)
{
byte[] hashedDataBytes;
System.Text.UTF8Encoding encoder = new System.Text.UTF8Encoding();
System.Security.Cryptography.MD5CryptoServiceProvider md5Hasher = new System.Security.Cryptography.MD5CryptoServiceProvider();
hashedDataBytes = md5Hasher.ComputeHash(encoder.GetBytes(strPlainText));
string a = "";
foreach (byte b in hashedDataBytes)
{
a += b.ToString();
}
return a;
}

No hay comentarios: