Beispiel #1
0
        public long CreateChecksum()
        {
            Adler32 adler32 = new Adler32();
            long a1 = 0, a2 = 0;
            byte[] header_value = new byte[Header];
            content.Seek(0, SeekOrigin.Begin);
            content.Read(header_value, 0, Header);
            for (int i = 0; i < Header; i += 6) {
                int pos = ByteBuffer.ReadInt4(header_value, i);
                int len = ((int)ByteBuffer.ReadInt2(header_value, i + 4)) & 0x0FFFF;

                byte[] node = new byte[len];
                content.Seek(pos, SeekOrigin.Begin);
                content.Read(node, 0, len);

                if ((i & 0x01) == 0) {
                    a1 = adler32.adler32(a1, node, 0, len);
                } else {
                    a2 = adler32.adler32(a2, node, 0, len);
                }
            }

            // Return the 64 bit value checksum,
            return (a1 << 32) | a2;
        }
Beispiel #2
0
 public void free()
 {
     next_in = null;
     next_out = null;
     msg = null;
     _adler = null;
 }
Beispiel #3
0
        // copy as much as possible from the sliding window to the output area
        internal int inflate_flush(ZStream z, int r)
        {
            int n;
            int p;
            int q;

            // local copies of source and destination pointers
            p = z.next_out_index;
            q = read;

            // compute number of bytes to copy as far as end of window
            n = (int)((q <= write?write:end) - q);
            if (n > z.avail_out)
            {
                n = z.avail_out;
            }
            if (n != 0 && r == Z_BUF_ERROR)
            {
                r = Z_OK;
            }

            // update counters
            z.avail_out -= n;
            z.total_out += n;

            // update check information
            if (checkfn != null)
            {
                z.adler = check = Adler32.adler32(check, window, q, n);
            }

            // copy as far as end of window
            Array.Copy(window, q, z.next_out, p, n);
            p += n;
            q += n;

            // see if more to copy at beginning of window
            if (q == end)
            {
                // wrap pointers
                q = 0;
                if (write == end)
                {
                    write = 0;
                }

                // compute bytes to copy
                n = write - q;
                if (n > z.avail_out)
                {
                    n = z.avail_out;
                }
                if (n != 0 && r == Z_BUF_ERROR)
                {
                    r = Z_OK;
                }

                // update counters
                z.avail_out -= n;
                z.total_out += n;

                // update check information
                if (checkfn != null)
                {
                    z.adler = check = Adler32.adler32(check, window, q, n);
                }

                // copy
                Array.Copy(window, q, z.next_out, p, n);
                p += n;
                q += n;
            }

            // update pointers
            z.next_out_index = p;
            read             = q;

            // done
            return(r);
        }