示例#1
0
文件: Chunk.cs 项目: lubota/spartacus
 public bool hasGoodCRC()
 {
     CRC32 computedCRC = new CRC32();
     computedCRC.Update(type, 0, 4);
     computedCRC.Update(data, 0, (int) chunkLength);
     return (computedCRC.GetValue() == this.crc);
 }
        public bool hasGoodCRC()
        {
            CRC32 computedCRC = new CRC32();

            computedCRC.Update(type, 0, 4);
            computedCRC.Update(data, 0, (int)chunkLength);
            return(computedCRC.GetValue() == this.crc);
        }
示例#3
0
        public bool hasGoodCRC()
        {
            CRC32 cRC = new CRC32();

            cRC.Update(this.type, 0, 4);
            cRC.Update(this.data, 0, (int)this.chunkLength);
            return(cRC.GetValue() == this.crc);
        }
示例#4
0
        private Chunk GetChunk(System.IO.Stream inputStream)
        {
            Chunk chunk = new Chunk();

            chunk.length = GetUInt32(inputStream);               // The length of the data chunk.
            chunk.type   = GetNBytes(inputStream, 4);            // The chunk type.
            chunk.data   = GetNBytes(inputStream, chunk.length); // The chunk data.
            chunk.crc    = GetUInt32(inputStream);               // CRC of the type and data chunks.

            CRC32 crc = new CRC32();

            crc.Update(chunk.type, 0, 4);
            crc.Update(chunk.data, 0, (int)chunk.length);
            if (crc.GetValue() != chunk.crc)
            {
                throw new Exception("Chunk has bad CRC.");
            }

            return(chunk);
        }