16位元MD5加密:
public string Get16BitsMd5(string input)
{
MD5CryptoServiceProvider md5Hasher = new MD5CryptoServiceProvider();
byte[] myData = md5Hasher.ComputeHash(Encoding.Default.GetBytes(input));
StringBuilder sBuilder = new StringBuilder();
for (int i = 0; i < myData.Length; i++)
{
sBuilder.Append(myData[i].ToString("x"));
}
return sBuilder.ToString();
}
32位元MD5加密:
public string Get32BitsMd5(string input)
{
MD5CryptoServiceProvider md5Hasher = new MD5CryptoServiceProvider();
byte[] myData = md5Hasher.ComputeHash(Encoding.Default.GetBytes(input));
StringBuilder sBuilder = new StringBuilder();
for (int i = 0; i < myData.Length; i++)
{
sBuilder.Append(myData[i].ToString("x2"));
}
return sBuilder.ToString();
}
沒有留言:
張貼留言