Return to Snippet

Revision: 7725
at August 9, 2008 11:10 by Elph


Updated Code
// using System;
// using System.Text;
// using System.Security.Cryptography;

private string GetHash(string str)
{
    MD5 md5 = MD5CryptoServiceProvider.Create();
    ASCIIEncoding encoding = new ASCIIEncoding();
    StringBuilder sb = new StringBuilder();
    byte[] stream = md5.ComputeHash(encoding.GetBytes(str));
    for (int i = 0; i < stream.Length; i++)
    {
        sb.AppendFormat("{0:x2}", stream[i]);
    }
    return sb.ToString();
}

Revision: 7724
at August 9, 2008 11:08 by Elph


Initial Code
private string GetHash(string str)
        {
            MD5 md5 = MD5CryptoServiceProvider.Create();
            ASCIIEncoding encoding = new ASCIIEncoding();
            StringBuilder sb = new StringBuilder();
            byte[] stream = stream = md5.ComputeHash(encoding.GetBytes(str));
            for (int i = 0; i < stream.Length; i++)
            {
                sb.AppendFormat("{0:x2}", stream[i]);
            }
            return sb.ToString();
}

Initial URL

                                

Initial Description

                                

Initial Title
Calculate MD5 hash

Initial Tags

                                

Initial Language
C#