1Crypt::Checksum::CRC32(U3s)er Contributed Perl DocumentatCiroynpt::Checksum::CRC32(3)
2
3
4

NAME

6       Crypt::Checksum::CRC32 - Compute CRC32 checksum
7

SYNOPSIS

9          ### Functional interface:
10          use Crypt::Checksum::CRC32 ':all';
11
12          # calculate CRC32 checksum from string/buffer
13          $checksum_raw  = crc32_data($data);
14          $checksum_hex  = crc32_data_hex($data);
15          $checksum_int  = crc32_data_int($data);
16          # calculate CRC32 checksum from file
17          $checksum_raw  = crc32_file('filename.dat');
18          $checksum_hex  = crc32_file_hex('filename.dat');
19          $checksum_int  = crc32_file_int('filename.dat');
20          # calculate CRC32 checksum from filehandle
21          $checksum_raw  = crc32_file(*FILEHANDLE);
22          $checksum_hex  = crc32_file_hex(*FILEHANDLE);
23          $checksum_int  = crc32_file_int(*FILEHANDLE);
24
25          ### OO interface:
26          use Crypt::Checksum::CRC32;
27
28          $d = Crypt::Checksum::CRC32->new;
29          $d->add('any data');
30          $d->add('another data');
31          $d->addfile('filename.dat');
32          $d->addfile(*FILEHANDLE);
33          $checksum_raw = $d->digest;     # raw 4 bytes
34          $checksum_hex = $d->hexdigest;  # hexadecimal form
35          $checksum_int = $d->intdigest;  # 32bit unsigned integer
36

DESCRIPTION

38       Calculating CRC32 checksums.
39
40       Updated: v0.057
41

EXPORT

43       Nothing is exported by default.
44
45       You can export selected functions:
46
47        use Crypt::Checksum::CRC32 qw(crc32_data crc32_data_hex crc32_data_int crc32_file crc32_file_hex crc32_file_int);
48
49       Or all of them at once:
50
51        use Crypt::Checksum::CRC32 ':all';
52

FUNCTIONS

54   crc32_data
55       Returns checksum as raw octects.
56
57        $checksum_raw = crc32_data('data string');
58        #or
59        $checksum_raw = crc32_data('any data', 'more data', 'even more data');
60
61   crc32_data_hex
62       Returns checksum as a hexadecimal string.
63
64        $checksum_hex = crc32_data_hex('data string');
65        #or
66        $checksum_hex = crc32_data_hex('any data', 'more data', 'even more data');
67
68   crc32_data_int
69       Returns checksum as unsigned 32bit integer.
70
71        $checksum_int = crc32_data_int('data string');
72        #or
73        $checksum_int = crc32_data_int('any data', 'more data', 'even more data');
74
75   crc32_file
76       Returns checksum as raw octects.
77
78        $checksum_raw = crc32_file('filename.dat');
79        #or
80        $checksum_raw = crc32_file(*FILEHANDLE);
81
82   crc32_file_hex
83       Returns checksum as a hexadecimal string.
84
85        $checksum_hex = crc32_file_hex('filename.dat');
86        #or
87        $checksum_hex = crc32_file_hex(*FILEHANDLE);
88
89   crc32_file_int
90       Returns checksum as unsigned 32bit integer.
91
92        $checksum_int = crc32_file_int('filename.dat');
93        #or
94        $checksum_int = crc32_file_int(*FILEHANDLE);
95

METHODS

97   new
98       Constructor, returns a reference to the checksum object.
99
100        $d = Crypt::Checksum::CRC32->new;
101
102   clone
103       Creates a copy of the checksum object state and returns a reference to
104       the copy.
105
106        $d->clone();
107
108   reset
109       Reinitialize the checksum object state and returns a reference to the
110       checksum object.
111
112        $d->reset();
113
114   add
115       All arguments are appended to the message we calculate checksum for.
116       The return value is the checksum object itself.
117
118        $d->add('any data');
119        #or
120        $d->add('any data', 'more data', 'even more data');
121
122   addfile
123       The content of the file (or filehandle) is appended to the message we
124       calculate checksum for.  The return value is the checksum object
125       itself.
126
127        $d->addfile('filename.dat');
128        #or
129        $d->addfile(*FILEHANDLE);
130
131       BEWARE: You have to make sure that the filehandle is in binary mode
132       before you pass it as argument to the addfile() method.
133
134   digest
135       Returns the binary checksum (raw bytes).
136
137        $result_raw = $d->digest();
138
139   hexdigest
140       Returns the checksum encoded as a hexadecimal string.
141
142        $result_hex = $d->hexdigest();
143
144   intdigest
145       Returns the checksum encoded as unsigned 32bit integer.
146
147        $result_int = $d->intdigest();
148

SEE ALSO

150       •   CryptX
151
152       •   <https://en.wikipedia.org/wiki/Cyclic_redundancy_check>
153
154
155
156perl v5.34.0                      2022-02-14         Crypt::Checksum::CRC32(3)
Impressum