SHA512Managed生成512位哈希值,使用方法很简单:
private string SHA512(string strPlain)
{
SHA512Managed sha512=new SHA512Managed();
string strHash=string.Empty;
byte[] btHash=sha512.ComputeHash(UnicodeEncoding.Unicode.GetBytes(strPlain));
for(int i=0;i<btHash.Length;i++)
{
strHash=strHash+Convert.ToString(btHash[i],16);
}
return strHash;
}
{
SHA512Managed sha512=new SHA512Managed();
string strHash=string.Empty;
byte[] btHash=sha512.ComputeHash(UnicodeEncoding.Unicode.GetBytes(strPlain));
for(int i=0;i<btHash.Length;i++)
{
strHash=strHash+Convert.ToString(btHash[i],16);
}
return strHash;
}