Created
July 7, 2017 15:23
-
-
Save schweigert/f56319b10f9659b537cc8d338995e75c to your computer and use it in GitHub Desktop.
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
| using System; | |
| using System.Text; | |
| using System.Security.Cryptography; | |
| namespace MD5test | |
| { | |
| class MainClass | |
| { | |
| public static void Main(string[] args) | |
| { | |
| Console.WriteLine(MD5Hash("Hello World!")); | |
| } | |
| public static string MD5Hash(string input) | |
| { | |
| // hash the string | |
| MD5 md5 = MD5.Create(); | |
| byte[] inputBytes = System.Text.Encoding.UTF8.GetBytes(input); | |
| byte[] hash = md5.ComputeHash(inputBytes); | |
| // convert to hex string | |
| StringBuilder sb = new StringBuilder(); | |
| for (int i = 0; i < hash.Length; i++) | |
| { | |
| sb.Append(hash[i].ToString("x2")); | |
| } | |
| return sb.ToString(); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment