Generating a criptographic hash of a stream in C#

using System.Security.Cryptography;
var algorithm = SHA256.Create();
var hash = await algorithm.ComputeHashAsync(stream);
return Convert.ToBase64String(hash);