Skip to content

Instantly share code, notes, and snippets.

@uzbekdev1
Forked from jasonyost/MD5.cs
Created March 1, 2019 11:31
Show Gist options
  • Save uzbekdev1/f90a3da7c68ba99f7ca209d4002e9c07 to your computer and use it in GitHub Desktop.
Save uzbekdev1/f90a3da7c68ba99f7ca209d4002e9c07 to your computer and use it in GitHub Desktop.
Create MD5 from string in C#
public static string MD5Hash(string input)
{
StringBuilder hash = new StringBuilder();
MD5CryptoServiceProvider md5provider = new MD5CryptoServiceProvider();
byte[] bytes = md5provider.ComputeHash(new UTF8Encoding().GetBytes(input));
for (int i = 0; i < bytes.Length; i++)
{
hash.Append(bytes[i].ToString("x2"));
}
return hash.ToString();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment