【发布时间】:2011-04-14 15:33:16
【问题描述】:
寻找一种在 C# 中从字符串执行以下操作的方法。
public static String sha512Hex(byte[] data)
计算 SHA-512 摘要并将值作为十六进制字符串返回。
参数: data - 要消化的数据 回报: SHA-512 摘要为十六进制字符串
private static string GetSHA512(string text)
{
UnicodeEncoding UE = new UnicodeEncoding();
byte[] hashValue;
byte[] message = UE.GetBytes(text);
SHA512Managed hashString = new SHA512Managed();
string encodedData = Convert.ToBase64String(message);
string hex = "";
hashValue = hashString.ComputeHash(UE.GetBytes(encodedData));
foreach (byte x in hashValue)
{
hex += String.Format("{0:x2}", x);
}
return hex;
}
【问题讨论】:
标签: c# encryption