/// <summary> /// Calculate content hash of content in a stream. /// </summary> public static Task <ContentHash> CalculateHashAsync(this StreamWithLength stream, HashType hashType) { #if NET_COREAPP if (stream.Stream is FileStream fileStream) { return(Task.FromResult(fileStream.HashFile(hashType))); } #endif // NET_COREAPP var hasher = HashInfoLookup.GetContentHasher(hashType); return(hasher.GetContentHashAsync(stream)); }
/// <summary> /// Calculate content hash of content in a stream. /// </summary> public static Task <ContentHash> CalculateHashAsync(this StreamWithLength stream, HashType hashType) { var hasher = HashInfoLookup.GetContentHasher(hashType); return(hasher.GetContentHashAsync(stream)); }
/// <summary> /// Calculate content hash of content in a byte array. /// </summary> public static ContentHash CalculateHash(this byte[] content, HashType hashType) { return(HashInfoLookup.GetContentHasher(hashType).GetContentHash(content)); }