using System; using System.IO; using System.Security.Cryptography; namespace Quadarax.Foundation.Core.IO { public static class StreamExt { public static string GetStreamCalculatedHash(this Stream stream, HashAlgorithm algorithm) { if (stream == null) throw new ArgumentNullException(nameof(stream)); if (algorithm == null) throw new ArgumentNullException(nameof(algorithm)); return BitConverter.ToString(algorithm.ComputeHash(stream)).Replace("-", "").ToLowerInvariant(); } } }