Skip to content

Instantly share code, notes, and snippets.

@viceo
Forked from madd0/md5.cs
Created June 11, 2020 01:55
Show Gist options
  • Save viceo/e228c14c5d63880a1562531a62f84a00 to your computer and use it in GitHub Desktop.
Save viceo/e228c14c5d63880a1562531a62f84a00 to your computer and use it in GitHub Desktop.
Create an MD5 hash digest in C#
public static string MD5Hash(string toHash)
{
string hashed;
using (MD5 md5 = MD5.Create())
{
hashed = string.Join(string.Empty, md5.ComputeHash(Encoding.UTF8.GetBytes(toHash)).Select(b => b.ToString("x2")));
}
return hashed;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment