Calculate MD5 Hash Guid - CSharp System.Security.Cryptography

CSharp examples for System.Security.Cryptography:MD5

Description

Calculate MD5 Hash Guid

Demo Code


using System.Text;
using System.Security.Cryptography;
using System;//from   ww  w . j a v a2s .c  o  m

public class Main{
        public static Guid CalculateMD5HashGuid(string input)
        {
            // step 1, calculate MD5 hash from input
            MD5 md5 = System.Security.Cryptography.MD5.Create();

            byte[] inputBytes = System.Text.Encoding.ASCII.GetBytes(input);
            byte[] hash = md5.ComputeHash(inputBytes);

            return new Guid(hash);
        }
}

Related Tutorials