public static string Calculate(Stream stream)
{
if (stream == null)
{
throw new ArgumentNullException("stream");
}
SHA256Managed sha = new SHA256Managed();
byte[] checksum = sha.ComputeHash(stream);
StringBuilder sb = new StringBuilder();
foreach (byte b in checksum)
{
sb.Append(b.ToString("X2"));
}
return sb.ToString();
}