} // func ReadStreamData private static (string hashName, byte[] hashValue) CopyData(bool shouldDeflate, Stream srcStream, byte[] buf, int readed, Stream dstStream) { // pack destination stream var dst = shouldDeflate ? new GZipStream(dstStream, CompressionMode.Compress, true) : dstStream; using (var dstHashStream = new HashStream(dst, HashStreamDirection.Write, false, SHA256.Create())) { try { // copy stream into file dstHashStream.Write(buf, 0, readed); srcStream.CopyTo(dst); } finally { dstHashStream.Flush(); dstHashStream.Dispose(); } dstHashStream.Close(); return("SHA2_256", dstHashStream.HashSum); } } // func CopyData
public static void Compute(HashAlgorithm hashAlgorithm, IUVStream stream, Action<byte[]> callback) { var hs = new HashStream(hashAlgorithm, stream); hs.Complete += () => { callback(hs.Hash); hs.Dispose(); }; }
public static void ComputeString(HashAlgorithm hashAlgorithm, IUVStream<ArraySegment<byte>> stream, Action<string> callback) { var hs = new HashStream(hashAlgorithm, stream); hs.Complete += () => { callback(hs.HashString); hs.Dispose(); }; }
public static void ComputeString(HashAlgorithm hashAlgorithm, IUVStream stream, Action <string> callback) { var hs = new HashStream(hashAlgorithm, stream); hs.Complete += () => { callback(hs.HashString); hs.Dispose(); }; }
public static void Compute(HashAlgorithm hashAlgorithm, IUVStream <ArraySegment <byte> > stream, Action <byte[]> callback) { var hs = new HashStream(hashAlgorithm, stream); hs.Complete += () => { callback(hs.Hash); hs.Dispose(); }; }