需要从字符串获取MD5哈希值。
出现错误,显示MD5为null。
我尝试从一个字符串获取32个字符的MD5哈希值。
using (System.Security.Cryptography.MD5 md5 =
System.Security.Cryptography.MD5.Create("TextToHash"))
{
byte[] retVal = md5.Hash;
StringBuilder sb = new StringBuilder();
for (int i = 0; i < retVal.Length; i++)
{
sb.Append(retVal[i].ToString("x2"));
}
}