public async Task <HashValue> ComputeHashAsync(Stream data, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); var hash = await xx.ComputeHashAsync(data, cancellationToken); return(new HashValue(hash.Hash)); }
public static async Task <string> ComputeHash(this string text) { using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(text))) { var value = await HashFunction.ComputeHashAsync(stream); return(value.AsBase64String()); } }
public static async Task <string> ComputeHash(this object obj) { var serialized = JsonConvert.SerializeObject(obj); using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(serialized))) { var value = await HashFunction.ComputeHashAsync(stream); return(value.AsBase64String()); } }
public async Task <byte[]> ComputeHashAsync(Stream stream) { return((await algorithm.ComputeHashAsync(stream).ConfigureAwait(false)).Hash); }