cksum's and zip's CRC32 algorithm

Hello!

For long I used cksum to find file duplicates in linux and darwin.
Now I want to make my own program that does all.
However I can't seem to find the correct algorithm.

zip and cksum claim to use the same algorithm, but the computated sums are not the same.
I've already written an algorithm that yelds the same result as zip, but what I want is the specifics of cksum's algorithm.

I already tried to find cksum's source but failed.

Any help is apreciated.

Define 'I already tried to find cksum's source but failed'

you cannot find the source code - or your found it and could not get it to work?

I tried doing some trial and error experimentation with my code and
CRC calculation
using a string with 6 characters, reversing or not the results and bit by bit computations
If is usefull I can post the source for my function.

Googled 'cksum source code' and saw about some 30 different links take where mainly to forum threads asking for the same thing and an old sum BSD code.
I also read it there should be somewhere in my linux dist (fedora 10) but I don't know where (package it comes in).

In some unixes the algorithm is described in "man cksum".
For example:

1p:cksum - Linux Man Pages Manual Documentation for Linux / Solaris / UNIX / BSD

/** Reverses bit order. MSB -> LSB and LSB -> MSB. */
unsigned int reverse(unsigned int x) {
    unsigned int ret = 0;
    for (int i=0; i<32; ++i) {
        if (x&0x1 != 0) {
            ret |= (0x80000000 >> i);
        }
        else {}
        x = (x >> 1);
    }
    return ret;
}

unsigned int crc32(unsigned char* message, unsigned int msgsize, unsigned int crc) {
    unsigned int i, j; // byte counter, bit counter
    unsigned int byte;
    unsigned int poly = 0x04C11DB7;
    i = 0;
    for (i=0; i<msgsize; ++i) {
        byte = message;       // Get next byte.
        byte = reverse(byte);    // 32-bit reversal.
        for (j=0; j<= 7; ++j) {  // Do eight times.
            if ((int)(crc ^ byte) < 0)
                crc = (crc << 1) ^ poly;
            else crc = crc << 1;
            byte = byte << 1;    // Ready next msg bit.
        }
    }
    return reverse(~crc);
}

This is the code I'm using. It reproduces the same results as zip's CRC32.
(try zipping a small file and then unzip -v file on the cmdline). The poly is the same as the one mentioned in the cksum man page.

methyl thanks for the link, it has some pseudo code new to me. I'll try to find the Sarwate article about table generation, maybe it will cast some light on what is done different in cksum.

btw the code was adapted from Software Implementations