Exemple #1
0
        public static int GetStreamCRC32(Stream stream)
        {
            zLib.Checksums.IChecksum crc = new zLib.Checksums.Crc32();
            crc.Reset();

            int len;

            byte[] buffer = new byte[512];

            while ((len = stream.Read(buffer, 0, 512)) > 0)
            {
                crc.Update(buffer, 0, len);
            }

            return(( int )crc.Value);
        }
Exemple #2
0
        public static int GetStreamCRC32(Stream stream, int count)
        {
            zLib.Checksums.IChecksum crc = new zLib.Checksums.Crc32();
            crc.Reset();
            byte[] b = new byte[1];

            for (int i = 0; i < count; i++)
            {
                int len = stream.Read(b, 0, b.Length);
                if (len == 0)
                {
                    return(0);
                }

                crc.Update(b);
            }

            return(( int )crc.Value);
        }