AniDBmini.HashAlgorithms.Ed2k.ComputeHash C# (CSharp) Method

ComputeHash() public method

public ComputeHash ( Stream stream ) : byte[]
stream System.IO.Stream
return byte[]
        public new byte[] ComputeHash(Stream stream)
        {
            size = stream.Length;
            totalBytesRead = 0;

            isHashing = true;

            // Default the buffer size to 4K.
            byte[] buffer = new byte[4096];
            int bytesRead;
            do
            {
                bytesRead = stream.Read(buffer, 0, 4096);
                if (bytesRead > 0)
                {
                    HashCore(buffer, 0, bytesRead);
                }
            } while (bytesRead > 0 && isHashing);

            if (!isHashing)
            {
                Initialize();
                return null;
            }

            HashValue = HashFinal();
            byte[] Tmp = (byte[])HashValue.Clone();
            Initialize();

            return Tmp;
        }