CRC32(3)

πŸ’… CRC32(3) β€” like, the String::CRC32 situation

okay bestie, so this is the CRC32(3) page from the User Contributed Perl Documentation and it's genuinely so useful, you're gonna be obsessed 🫢


✨ NAME ✨

String::CRC32 β€” a Perl interface for cyclic redundancy check generation πŸ’–


🌸 SYNOPSIS 🌸

use String::CRC32;

$crc = crc32("some string");
$crc = crc32("some string", initvalue);

$somestring = "some string";
$crc = crc32($somestring);
printf "%08x\n", $crc;

open my $fh, '<', 'location/of/some.file' or die $!;
binmode $fh;
$crc = crc32($fh);
close $fh;

like, that's it, that's the whole vibe check πŸ’€βœ¨


πŸ¦‹ DESCRIPTION πŸ¦‹

So the CRC32 module calculates CRC sums of 32 bit lengths as integers. No cap, it generates the same CRC values as ZMODEM, PKZIP, PICCHECK and, like, many others too πŸ‘‘

And despite its name β€” plot twist πŸŽ€ β€” this module is literally able to compute the checksum of files as well as strings. Both. It's giving versatility, honestly.


πŸ“ EXAMPLES πŸ“

okay so watch this:

$crc = crc32("some string");

results in the same thing as:

$crc = crc32(" string", crc32("some"));

lowkey iconic, right?? This is useful for subsequent CRC checking of substrings πŸ’…βœ¨

And you may even check files:

open my $fh, '<', 'location/of/some.file' or die $!;
binmode $fh;
$crc = crc32($fh);
close $fh;

ngl an init value may also have been supplied in the above example πŸ‘€ fr fr.


πŸŽ€ AUTHOR πŸŽ€

Soenke J. Peters <peters__perl@opcenter.de>

Current maintainer: LEEJO

Address bug reports and comments to: <https://github.com/leejo/string-crc32/issues> β€” like, pls do, they wanna hear from u 🫢


πŸ’œ LICENSE πŸ’œ

CRC algorithm code taken from CRC-32 by Craig Bruce. The module stuff is inspired by a similar perl module called String::CRC by David Sharnoff & Matthew Dillon. Horst Fickenscher told me that it could be useful to supply an init value to the crc checking function and so I included this possibility πŸ’–

The author of this package disclaims all copyrights and releases it into the public domain. periodt. πŸŽ€πŸ‘‘


cute sign-off time ✨ this lil masterpiece is from perl v5.42.0, dated 2021-02-05, and it lives at CRC32(3) forever and ever πŸ¦‹πŸ’– slay.