Skip to content

Instantly share code, notes, and snippets.

@xplicit
Last active May 31, 2016 12:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xplicit/82e68389d6ccc757948d462e406af6b6 to your computer and use it in GitHub Desktop.
Save xplicit/82e68389d6ccc757948d462e406af6b6 to your computer and use it in GitHub Desktop.
Compute MD5 hash
//Compute md5
using System.Security.Cryptography;
using System.Text;
string code = "Hello, World!";
string hash;
using (MD5 md5 = MD5.Create())
{
byte[] retVal = md5.ComputeHash(Encoding.Unicode.GetBytes(code));
StringBuilder sb = new StringBuilder();
for (int i = 0; i < retVal.Length; i++)
{
sb.Append(retVal[i].ToString("x2"));
}
hash = sb.ToString();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment