Esempio n. 1
0
        internal static TaskSequence ComputeMD5(this Stream stream, Action <string> setResult)
        {
            int readCount;
            MD5 md5 = MD5.Create();

            do
            {
                byte[] buffer   = new byte[BufferSize];
                var    readTask = stream.ReadAsync(buffer, 0, buffer.Length);
                yield return(readTask);

                readCount = readTask.Result;

                StreamUtilities.ComputeHash(buffer, 0, readCount, md5);
            }while (readCount != 0);

            setResult(StreamUtilities.GetHashValue(md5));
        }