/// <summary> /// 返回将str以md5方式加密后的字符串 /// </summary> /// <param name="str"></param> /// <returns></returns> public static string MD5(string str) { byte[] bytes = Encoding.Default.GetBytes(str); bytes = new MD5CryptoServiceProvider().ComputeHash(bytes); string text = ""; for (int i = 0; i < bytes.Length; i++) { text = text + bytes[i].ToString("x").PadLeft(2, '0'); } return text; }