Get MD5 32 bit - CSharp Security

CSharp examples for Security:MD5

Description

Get MD5 32 bit

Demo Code


using System.Runtime.Serialization.Formatters.Binary;
using System.Configuration;
using System.Net;
using System.Net.Mail;
using System.Drawing;
using System.Xml.Xsl;
using System.Xml;
using System.Data;
using System.Data.OleDb;
using System.IO;//  ww w.  j  a v a2 s  .  c om
using System.Web.Security;
using System.Security.Cryptography;
using System.Text.RegularExpressions;
using System.Text;
using System.Collections;
using System.Web;
using System.Linq;
using System.Collections.Generic;
using System;

public class Main{

        public static string GetMD5_32(string s, string _input_charset)
        {
            MD5 md5 = new MD5CryptoServiceProvider();
            byte[] t = md5.ComputeHash(Encoding.GetEncoding(_input_charset).GetBytes(s));
            StringBuilder sb = new StringBuilder(32);
            for (int i = 0; i < t.Length; i++)
            {
                sb.Append(t[i].ToString("x").PadLeft(2, '0'));
            }
            return sb.ToString();
        }
}

Related Tutorials