CSharp examples for System.Security.Cryptography:MD5
MD5 Encrypt String
using System.Web; using System.Text; using System.Security.Cryptography; using System.Linq; using System.Collections.Generic; using System;//from w w w. j a va 2 s .c om public class Main{ public static string MD5Encrypt(string str) { MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider(); byte[] encryptedBytes = md5.ComputeHash(Encoding.ASCII.GetBytes(str)); StringBuilder sb = new StringBuilder(); for (int i = 0; i < encryptedBytes.Length; i++) { sb.AppendFormat("{0:x2}", encryptedBytes[i]); } return sb.ToString().ToUpper(); } }