static string hex_md5(string input) { // Create a new instance of the MD5CryptoServiceProvider object. System.Security.Cryptography.MD5 md5Hasher = System.Security.Cryptography.MD5.Create(); // Convert the input string to a byte array and compute the hash. byte[] data = md5Hasher.ComputeHash(Encoding.Default.GetBytes(input)); // Create a new Stringbuilder to collect the bytes // and create a string. StringBuilder sBuilder = new StringBuilder(); // Loop through each byte of the hashed data // and format each one as a hexadecimal string. for (int i = 0; i < data.Length; i++) { sBuilder.Append(data[i].ToString("x2")); // x2- Lower case, X2- Upper case } // Return the hexadecimal string. return sBuilder.ToString(); } ... Console.WriteLine(hex_md5("1"));
c4ca4238a0b923820dcc509a6f75849b
Retrieved from http://hyacinth.byus.net/moniwiki/wiki.php/C_Sharp/Hash
last modified 2014-04-01 19:06:00