/// <summary>Calculates the Adler32 check-sum on specified portion of a buffer.</summary> /// <param name="data">Data buffer to perform check-sum on.</param> /// <param name="startIndex">Starts index in data buffer to begin check-sum.</param> /// <param name="length">Total number of bytes from <paramref name="startIndex">startIndex</paramref> to /// perform check-sum over.</param> /// <remarks> /// <para> /// Computes Adler32 checksum for a stream of data. An Adler32 checksum is not as reliable as a CRC32 /// checksum, but a lot faster to compute. /// </para> /// <para> /// The specification for Adler32 may be found in RFC 1950. ZLIB Compressed Data Format Specification /// version 3.3. /// </para> /// </remarks> /// <returns>Computed Adler32 checksum over the specified portion of the buffer.</returns> public static uint Adler32Checksum(this byte[] data, int startIndex, int length) { Adler32 checksum = new Adler32(); checksum.Update(data, startIndex, length); return checksum.Value; }
/// <summary> /// Creates a new inflater. /// </summary> /// <param name="noHeader"> /// True if no RFC1950/Zlib header and footer fields are expected in the input data /// /// This is used for GZIPed/Zipped input. /// /// For compatibility with /// Sun JDK you should provide one byte of input more than needed in /// this case. /// </param> public Inflater(bool noHeader) { this.noHeader = noHeader; this.adler = new Adler32(); input = new StreamManipulator(); outputWindow = new OutputWindow(); mode = noHeader ? DECODE_BLOCKS : DECODE_HEADER; }
/// <summary> /// Construct instance with pending buffer /// </summary> /// <param name="pending"> /// Pending buffer to use /// </param>> public DeflaterEngine(DeflaterPending pending) { this.pending = pending; huffman = new DeflaterHuffman(pending); adler = new Adler32(); window = new byte[2 * WSIZE]; head = new short[HASH_SIZE]; prev = new short[WSIZE]; // We start at index 1, to avoid an implementation deficiency, that // we cannot build a repeat pattern at index 0. blockStart = strstart = 1; }