String Encrypt MD5 - CSharp Security

CSharp examples for Security:MD5

Description

String Encrypt MD5

Demo Code


using System.Web.Routing;
using System.Web.Mvc;
using System.Security.Cryptography;
using System.Collections.Generic;

public class Main{
        private static string EncryptMD5(string Value)
        {//from   w  ww.ja va2  s. c  om
            System.Security.Cryptography.MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
            byte[] valueArray = System.Text.Encoding.ASCII.GetBytes(Value);
            valueArray = md5.ComputeHash(valueArray);
            string encrypted = "";
            for (int i = 0; i < valueArray.Length; i++)
                encrypted += valueArray[i].ToString("x2").ToLower();
            return encrypted;
        }
}

Related Tutorials