转自:http://blog.bc-cn.net/user21/140817/archives/2007/4755.shtm
MD5 md5=new MD5CryptoServiceProvider();
byte[] bt=Encoding.Default.GetBytes("待加密字符串");//将待加密字符转为 字节型数组
byte[] resualt=md5.ComputeHash(bt);//将字节数组转为加密的字节数组
string pwds = BitConverter.ToString(resualt).Replace("-","");//将数字转为string 型去掉内部的无关字符