cksum does not give me crc32


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers cksum does not give me crc32
# 1  
Old 03-31-2011
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
# 2  
Old 03-31-2011
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.

Last edited by Corona688; 03-31-2011 at 02:33 PM..
# 3  
Old 03-31-2011
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.
# 4  
Old 03-31-2011
Quote:
Originally Posted by utamav
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?
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.

Last edited by Corona688; 03-31-2011 at 04:13 PM..
# 5  
Old 03-31-2011
Quote:
Originally Posted by Corona688
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
# 6  
Old 03-31-2011
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.
# 7  
Old 03-31-2011
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.

Last edited by Corona688; 03-31-2011 at 05:44 PM..
 
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

List all files with prepended CRC32 (or other) hash code?

I would like to list all files in a directory tree but with a prepended digest hash code (like CRC32). CRC32 is not a MUST. If suitable another hash code can be used as well. In case of CRC32 the listing should look like 3765AC \usr\bin\spool 23CE99 \usr\bin\spool\list.h ... 11AA04... (3 Replies)
Discussion started by: pstein
3 Replies

2. UNIX for Advanced & Expert Users

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... (4 Replies)
Discussion started by: regnevakrad
4 Replies

3. Shell Programming and Scripting

EEPROM CKSUM? what is this?

Hi all, So I have a binary file and I need to generate an expected EEPROM checksum for it. Ideally, I would like to input the file (with the path) and output a computed checksum. Ive been using (cksum file1) with no avail and I was just curious as to whether there is such thing as EEPROM cksum,... (1 Reply)
Discussion started by: TeamUSA
1 Replies

4. UNIX for Advanced & Expert Users

Cksum dependencies

Hi, On what factors does the cksum depend. If i build 2 machines exactly the same, then can i get the checksum of 2 compiled files same. Thanks (3 Replies)
Discussion started by: vibhor_agarwali
3 Replies

5. Shell Programming and Scripting

using cksum

hi, I am trying to use the cksum feature in unix. when i make a call to it i get returned something along the lines of: 4603435 14 file3 how do i get the first part of this response only; i.e: 4603435 I'm trying to use at a way without the use of sed and creating temp... (4 Replies)
Discussion started by: leeRoberts2007
4 Replies

6. Shell Programming and Scripting

cksum question

Hi there, I have a query about cksum. I'm running a script on the Unix box and in a script the cksum result differs from when I run it manually. As far as I can see the file is not being changed, is there any other times that the cksum would be different. (4 Replies)
Discussion started by: rjsha1
4 Replies

7. Shell Programming and Scripting

Anyone know how cksum works?

hello all. I'm not asking about the algorithm - or how it goes about computing the checksum - I'm asking how it views/looks at the files it does the cksum on. For instance: Say you had a directory named "dir_A" And within this directory you had some files. So: dir_A - file1 -... (5 Replies)
Discussion started by: kapolani
5 Replies

8. Programming

crc32 info

hello again, does anyone know where i can find some detailed info about the cyclic redundancy check? thx (2 Replies)
Discussion started by: crashnburn
2 Replies
Login or Register to Ask a Question