# Create random file    
$ dd if=/dev/urandom /of=./test.dat bs=1K count=1

# Zip it 
$ zip test.zip test.dat

# Dump contents for ZIP-computed CRC
$ unzip -v test.zip
Archive:  test.zip
Length   Method    Size  Cmpr    Date    Time   CRC-32   Name
--------  ------  ------- ---- ---------- ----- --------  ----
    1024  Stored     1024   0% 2018-12-09 17:42 1f197320  test.dat
--------          -------  ---                            -------
    1024             1024   0%                            1 file

# compute CRC with coreutil's cksum
$ cksum test.dat
283837118 1024 test.dat

# convert to hex
$ printf "%08x" 283837118

TL;DR: cksum doesn't use the same CRC algorithm as ZIP.


Yes, you can use the crc32 command which is available in the Archive::Zip Perl module. On Debian and derivatives, install libarchive-zip-perl to get it.

  • I want to add a warning about undocumented behavior of the crc32 command. If the filename contains something that looks like a CRC32, it will compare it to the computed CRC and add a message to the stdout about whether it matches! I wonder how many scripts this has messed up? Btw, guess what looks like a CRC32? A date in the format 20200630! – Nick S Jun 30 '20 at 4:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.