LinuxCommandLibrary

crc32

Calculate the CRC32 checksum of a file

SYNOPSIS

crc32 [OPTION]... [FILE]...

PARAMETERS

-a ALG, --algorithm=ALG
    use CRC algorithm ALG (crc32, crc32c, crc32d, crc32q)

-h, --help
    display this help and exit

-l LEN, --length=LEN
    only hash the first LEN bytes

-V, --version
    display version information and exit

DESCRIPTION

The crc32 command calculates 32-bit Cyclic Redundancy Check (CRC) checksums for files or data from standard input. CRC32 is a non-cryptographic hash function used for error detection in data storage, transmission, and formats like ZIP, PNG, Ethernet, and iSCSI. It detects accidental corruption but is vulnerable to deliberate attacks due to collisions.

To use, provide filenames: crc32 document.txt outputs a hexadecimal checksum like 4a17b156. Omit files or use - for stdin: curl example.com/data | crc32. Each line shows checksum filename format.

Key features include algorithm selection (crc32 default, crc32c for better performance, others) and byte limiting for partial checks. It's lightweight and fast, ideal for scripts verifying archive integrity or network packets. Install via package managers (e.g., apt install crc32 on Debian-based systems).

Not for security: prefer sha256sum for tamper resistance. Common in build systems and data pipelines.

CAVEATS

CRC32 offers weak collision resistance; unsuitable for security or verifying intentional changes. Not in coreutils—requires separate installation.

EXAMPLES

crc32 file.txt
echo 'hello' | crc32
crc32 -a crc32c -l 1024 large.bin

OUTPUT FORMAT

Hexadecimal checksum (8 chars) followed by space and filename (or empty for stdin).

HISTORY

CRC-32 polynomials emerged in 1975 (Ethernet standard); crc32c (Castagnoli) in 1993 for better detection. Linux crc32 utility added ~2010 via community packages like Ubuntu's crc32 (version 1.4+).

SEE ALSO

cksum(1), md5sum(1), sha256sum(1), rhash(1)

Copied to clipboard