cosimo/perl6-string-crc32/lib/String/CRC32

perl6-string-crc32 src

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", :bin, :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

(head2) C
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'

 
(head2) C
Reads the whole file and calculates the CRC of that file. Example:
    use v6;
    use String::CRC32;

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

 

AUTHOR

Cosimo Streppone, E<lt>cosimo@cpan.orgE<gt> Most bits shamelessly stolen from L<String::CRC32> for Perl 5, version 1.4 by Sönke J. Peters.

COPYRIGHT

I hereby include the COPYRIGHT section for Perl5 L<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.

 

Perl 6 Tricks and Treats newsletter

Register to the free newsletter now, and get updates and news.
Email:
Name: