title: C zlib crc32 and Python zlib crc32 doesn't match
body: <p>Im experimenting a bit with crc32 in Python and C but my results won't match.</p>
  
  <pre><code>C:
  #include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;zlib.h&gt;
  
  #define NUM_BYTES 9
  
  int
  main(void)
  {
  
    uint8_t bytes[NUM_BYTES] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
  
    uint32_t crc = crc32(0L, Z_NULL, 0);
  
    for (int i = 0; i &lt; NUM_BYTES; ++i) {
      crc = crc32(crc, bytes, 1);
    }
  
    printf("CRC32 value is: %" PRIu32 "\n", crc);
  }
  </code></pre>
  
  <p>Gives the output <code>CRC32 value is: 3136421207</code></p>
  
  <p>Python</p>
  
  <pre><code>In [1]: import zlib
  In [2]: int(zlib.crc32("123456789") + 2**32)
  Out[2]: 3421780262
  </code></pre>
  
  <p>In python I'm adding with 2**32 to "cast" to unsigned int.</p>
  
  <p>What am I missing here?</p>
  
  <p>[edit 1]</p>
  
  <p>Now I have tried with</p>
  
  <pre><code>In [8]: crc = 0;
  In [9]: for i in xrange(1,10):
     ...:     crc = zlib.crc32(str(i), crc)
     ...:     
  In [10]: crc
  Out[10]: -873187034
  In [11]: crc+2**32
  Out[11]: 3421780262
  </code></pre>
  
  <p>and</p>
  
  <pre><code>int
  main(void)
  {
  
    uint32_t value = 123456789L;
  
    uint32_t crc = crc32(0L, Z_NULL, 0);
  
    crc = crc32(crc, &amp;value, 4);
  
    printf("CRC32 value is: %" PRIu32 "\n", crc);
  }
  </code></pre>
  
  <p>Still not the same result.</p>