Last active
May 31, 2016 12:00
-
-
Save xplicit/82e68389d6ccc757948d462e406af6b6 to your computer and use it in GitHub Desktop.
Compute MD5 hash
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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