trevorr / circe

Circe: A High-Performance Hash Algorithm Framework & Library
Apache License 2.0
12 stars 1 forks source link

CRC32C Incremental-Checksum is not giving correct result #3

Closed rdhabalia closed 8 years ago

rdhabalia commented 8 years ago

Hi,

I have created following test-case in CRCTest to verify incremental CRC32C checksum computation.

   @Test
    public void testCRC32CIncremental() {
        IncrementalIntHash crc32c = PROVIDER.getIncrementalInt(CRC32C);
        String data = "data";
        String combine = data + data;

        int combineChecksum = crc32c.calculate(combine.getBytes());
        int dataChecksum = crc32c.calculate(data.getBytes()); 
        int incrementalChecksum = crc32c.resume(dataChecksum, data.getBytes());
        assertEquals(combineChecksum, incrementalChecksum);
    }

We have two separate ByteBuffers and we want to compute combined-checksum on it so, I am trying to use incremental checksum but it seems it is giving incorrect result. @trevorr Can you please advice if I am missing anything here.

trevorr commented 8 years ago

Good catch. The reflection in ReflectedIntCrc should be on the initial value, not on each resume. I'll push a fix shortly.