Einen String in MD5 verschlüsseln
public string CreateMD5Hash (string input)
{
MD5 md5 = System.Security.Cryptography.MD5.Create();
byte[] inputBytes = System.Text.Encoding.ASCII.GetBytes (input);
byte[] hashBytes = md5.ComputeHash (inputBytes);
StringBuilder sb = new StringBuilder();
for (int i = 0; i < hashBytes.Length; i++)
{
sb.Append (hashBytes[i].ToString ("X2"));
}
return sb.ToString();
}
4 Kommentare zum Snippet