WinForm下对 中文字符串MD5 加密
http://topic.csdn.net/t/20050807/11/4193724.html
这里有个帖 加密结果跟
站长工具http://tools.chinaz.com/ 下面的 32位MD5加密结果不一样
但是加密英文和数字结果是没有错的
就加密中文 结果不对
public static string Get32MD5(string str) { byte[] b = System.Text.Encoding.Default.GetBytes(str); b = new System.Security.Cryptography.MD5CryptoServiceProvider().ComputeHash(b); string ret = ""; for (int i = 0; i < b.Length; i++) { ret += b[i].ToString("X").PadLeft(2, '0'); } return ret; }
// 试试以下之一:byte[] b = System.Text.Encoding.UTF8.GetBytes(str); byte[] b = System.Text.Encoding.Unicode.GetBytes(str); byte[] b = System.Text.Encoding.GetEncoding("GB18030").GetBytes(str);