MD Crypt - CSharp Security

CSharp examples for Security:MD5

Description

MD Crypt

Demo Code


using System.Drawing.Imaging;
using System.Drawing;
using System.IO;//from  w  w w  .  j av a  2  s. c  om
using System.Security.Cryptography;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System;

public class Main{
        public static string MD5Crypt(string Text)
        {
            string strMD5Result = "";
            try
            {
                byte[] arryByte = Encoding.Default.GetBytes(Text);
                MD5 md5 = new MD5CryptoServiceProvider();
                byte[] arryHashByte = md5.ComputeHash(arryByte);      
                strMD5Result = BitConverter.ToString(arryHashByte);
                strMD5Result = strMD5Result.Replace("-", String.Empty);      
            }
            catch (System.ArgumentNullException)
            {
                throw;
            }

            return strMD5Result;
        }
}

Related Tutorials