String::CRC32

Simple Perl 6 class to calculate a CRC32 checksum of a string

NAME

String::CRC32 - Calculate 32-bit CRC checksum of strings

SYNOPSIS

use v6;
    use String::CRC32;
# CRC of a string
    my $string = 'Hello, world';
    my $crc32 = String::CRC32::crc32($string);
# CRC of a filehandle
    my $fh = open("myfile", :r);
    $crc32 = String::CRC32::crc32($fh);
    $fh.close();

DESCRIPTION

The CRC32 module calculates CRC sums of 32 bit lenghts. It generates the same CRC values as ZMODEM, PKZIP, PICCHECK and many others.

METHODS

crc32($string)

Calculates and returns a CRC32 checksum of a string. For an example, see the SYNOPSIS.

Example:

use v6;
    use String::CRC32;
my $string = 'Hello, world';
    say String::CRC32::crc32($string);
# prints '3885672898'

crc32($fh)

Reads the whole file and calculates the CRC of that file.

Example:

use v6;
    use String::CRC32;
my $fh = open("myfile.txt", :r);
    say String::CRC32::crc32($fh);
    $fh.close();

AUTHOR

Cosimo Streppone, <[email protected]>

Most bits shamelessly stolen from String::CRC32 for Perl 5, version 1.4 by Sönke J. Peters.

COPYRIGHT

I hereby include the COPYRIGHT section for Perl5 String::CRC32:

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 Camelia image is copyright 2009 by Larry Wall. "Raku" is a trademark of the Yet Another Society. All rights reserved.

Built with Podlite — the markup and publishing tools behind this site.