asp.net开发中利用MD5加密(转换后为32位字节长度)
//利用MD5加密(转换后为32位字节长度)
public static string StringToMD5Hash(string inputString)
{
System.Security.Cryptography.MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
byte[] encryptedBytes=md5.ComputeHash(System.Text.Encoding.ASCII.GetBytes(inputString));
System.Text.StringBuilder sb=new StringBuilder();
for(int i=0;i<encryptedBytes.Length;i++)
{
sb.AppendFormat("{0:x2}",encryptedBytes[i]);
}
return sb.ToString();
}
public static string StringToMD5Hash(string inputString)
{
System.Security.Cryptography.MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
byte[] encryptedBytes=md5.ComputeHash(System.Text.Encoding.ASCII.GetBytes(inputString));
System.Text.StringBuilder sb=new StringBuilder();
for(int i=0;i<encryptedBytes.Length;i++)
{
sb.AppendFormat("{0:x2}",encryptedBytes[i]);
}
return sb.ToString();
}