/ Published in: C#

Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
/// <summary> /// Hash an input string and return the hash as a 32 character hexadecimal string. /// </summary> /// <param name="input"></param> /// <returns></returns> public string MD5(string input) { byte[] textBytes = System.Text.Encoding.Default.GetBytes(input); try { System.Security.Cryptography.MD5CryptoServiceProvider cryptHandler; byte[] hash = cryptHandler.ComputeHash(textBytes); string ret = ""; foreach (byte a in hash) { if (a < 16) ret += "0" + a.ToString("x"); else ret += a.ToString("x"); } return ret; } catch { throw; } }
Comments
