public void GetMD5Base()
{
MD5 md5 = MD5.Create();
string input = txtString.Text;
byte[] buffer = Encoding.UTF8.GetBytes(input); //字符串转成byte[ ]数组
byte[] newBuffer = md5.ComputeHash(buffer, 0, buffer.Length);
StringBuilder sb = new StringBuilder();
for (int i = 0; i < newBuffer.Length; i++)
{
sb.Append(newBuffer[i].ToString("X2"));
}
byte[] baseBuffer = Encoding.UTF8.GetBytes(sb.ToString()); //把转码后的MD5 32位密文转成byte[ ]
txtNeed.Text = Convert.ToBase64String(baseBuffer); //这个要注意,不要在newbuffer就转,你解密的时候会乱码(有时候)
}