其实和C#的代码是一样的,完全可以复用,这里给出相应的代码

/// /// MD5 /// /// /// public string MD5Hash(string strText) { MD5 MD5 = new MD5CryptoServiceProvider(); byte[] datSource = encoding.GetBytes(strText); byte[] newSource = MD5.ComputeHash(datSource); string byte2String = null; for (int i = 0; i < newSource.Length; i++) { string thisByte = newSource[i].ToString(“x”); if (thisByte.Length == 1) thisByte = “0” + thisByte; byte2String += thisByte; } return byte2String.ToUpper(); }