cksum does not give me crc32

Is cksum the right command to calculate the crc32 checksum value? I tried it for a number of files now and every time the results dont match. So there is nothing wrong with the file. Also, cksum gives me an all numerical value while crc32 is alpha numeric. What am I doing wrong?

Thanks

The unix cksum utility does use 32-bit CRC's -- it calculates them the same way ethernet checksums are. But there's more than one way to calculate a 32-bit CRC and more than one way to print one -- hexadecimal ff, hexadecimal FF, and decimal 255 are all the same number but different strings -- and your system's endian may differ too. You can't compare cksum's output string against anything but cksum's output string unless you get the implementation exactly right.

If your system is Tru64, that's a weird one that does some other sort of CRC.

You'll find a normal implementation here in cksum.c.

Now this makes thing very complicated and I dont understand why. I downloaded a program from the internet while calculates the checksum for a file and gives the crc32 output and it matched perfectly. Now if the crc32 can be displayed in many forms and format the probability of this random program showing me the correct crc32 value is astronomical. Isnt there a standard defined somewhere? Also is there a way to see all the variations of the crc32 value if I have one given by my unix system.

There's lots of standards, but it's not all one giant thing.

CRC32 is just the algorithm. It's standard, but there's several ways to use it -- you get some choice about things like whether the count starts from 0x00000000 or 0xffffffff, whether you use the value or the inverted value, etc.

Ethernet uses crc32 checksums for its frames, so they had to define all the bits CRC32 left open to choice or interpretation to make sure every network card and driver is willing to talk to each other. But network cards don't print anything, so they didn't define anything for that.

cksum is a UNIX standard utility using the CRC32 checksum algorithm from ethernet, and it defines how to print the number. It's always the same everywhere. (Except Tru64. They had to be special.)

As for every possible output? There's as many ways to print it as your imagination will allow, though most of them are pointless. What's most likely to be different is the number base, and you can convert that. Show me the two different checksums on the same file, and tell me what utility created it, and I might find a way to turn one into the other.

Created by the application: 338236be
eXpress checksum calculator (www(dot)irnis(dot)net/soft/xcsc/) <--- Sorry could not give you the link, coz the forum does not allow to post URLs before 5 posts.

Created by unix: 2702824077

There are lots of different CRC-32 algorithms in use and many more could be devised. The polynomial used in the calculation varies among them. This page list some of them. The CRC-32 used by and Unix that meets Posix requirements is the IEEE CRC-32. That utility probably is using another CRC - 32. They are both real CRC -32's but the Unix version is standard.

Okay, I have no idea where it's getting that CRC value from that input. Since it's a closed source program, I probably never will. But the cksum program follows a standard while your windows program didn't have to and could've followed any variety.

You can get a windows version of cksum as part of unxutils.

Can you post the source code for your crc.

He's using a closed-source Windows program.

:wall: