Calculate MD5 Hash Bytes - CSharp System.Security.Cryptography

CSharp examples for System.Security.Cryptography:MD5

Description

Calculate MD5 Hash Bytes

Demo Code


using System.Text;
using System.Security.Cryptography;
using System;/*  w w w  . j  ava  2 s.  c o  m*/

public class Main{
        public static byte[] CalculateMD5HashBytes(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 hash;
        }
}

Related Tutorials