Looking for a way to do the following in C # from a string.
public static String sha512Hex (byte [] data)
Computes the SHA-512 digest and returns the value as a hexadecimal string.
Parameters: data - data for digestion Returns: SHA-512 digest as a hexadecimal string
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;
}
Tom s source
share