Get MD5 for a string : MD5 « Security « C# / C Sharp






Get MD5 for a string

 

using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Security.Cryptography;

namespace PeDALS.Utilities.Hasher
{
    public static class GenerateHash
    {
        public static string GetMD5(string path)
        {
            byte[] HashValue, MessageBytes = File.ReadAllBytes(path);
            MD5 md5 = new MD5CryptoServiceProvider();
            string strHex = "";

            HashValue = md5.ComputeHash(MessageBytes);
            foreach (byte b in HashValue)
            {
                strHex += String.Format("{0:x2}", b);
            }
            return strHex;
        }

    }
}

   
  








Related examples in the same category

1.MD5 encode
2.MD5 Encrypt
3.Create MD5 Hash
4.Create ASCII MD5 Hash
5.Encrypt MD5
6.MD5 Hash
7.MD5 Hash
8.Get MD5 Hash
9.Makes a MD5 hash from a string
10.Get MD5 Hash (2)
11.Computes the MD5 checksum for a single file.
12.Get and verify MD5 Hash
13.Md5 Hash (2)