Esempio n. 1
0
            }             // 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
Esempio n. 2
0
 public static void Compute(HashAlgorithm hashAlgorithm, IUVStream stream, Action<byte[]> callback)
 {
     var hs = new HashStream(hashAlgorithm, stream);
     hs.Complete += () => {
         callback(hs.Hash);
         hs.Dispose();
     };
 }
Esempio n. 3
0
	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();
		};
	}
Esempio n. 4
0
    public static void ComputeString(HashAlgorithm hashAlgorithm, IUVStream stream, Action <string> callback)
    {
        var hs = new HashStream(hashAlgorithm, stream);

        hs.Complete += () => {
            callback(hs.HashString);
            hs.Dispose();
        };
    }
Esempio n. 5
0
    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();
        };
    }