Return to Snippet

Revision: 21903
at December 23, 2009 09:25 by tomaszsimon


Initial Code
public static string MD5(string password)
        {
            byte[] textBytes = System.Text.Encoding.Default.GetBytes(password);
            try
            {
                System.Security.Cryptography.MD5CryptoServiceProvider cryptHandler;
                cryptHandler = new System.Security.Cryptography.MD5CryptoServiceProvider();
                byte[] hash = cryptHandler.ComputeHash(textBytes);
                string ret = "";
                foreach (byte a in hash)
                {
                    ret += a.ToString("x2");
                }
                return ret.ToUpper(); ;
            }
            catch
            {
                throw;
            }
        }

Initial URL
http://www.spiration.co.uk/post/1203/MD5%20in%20C%23%20-%20works%20like%20php%20md5%28%29%20example

Initial Description


Initial Title
MD5 checksum returned as a string

Initial Tags


Initial Language
C#