File Coverage

blib/lib/Crypt/Digest/BLAKE2s_160.pm
Criterion Covered Total %
statement 29 30 96.6
branch n/a
condition 1 3 33.3
subroutine 15 16 93.7
pod 11 11 100.0
total 56 60 93.3


line stmt bran cond sub pod time code
1             package Crypt::Digest::BLAKE2s_160;
2              
3             ### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
4              
5 2     2   1264 use strict;
  2         4  
  2         73  
6 2     2   11 use warnings;
  2         3  
  2         135  
7             our $VERSION = '0.089_001';
8              
9 2     2   9 use base qw(Crypt::Digest Exporter);
  2         19  
  2         397  
10             our %EXPORT_TAGS = ( all => [qw( blake2s_160 blake2s_160_hex blake2s_160_b64 blake2s_160_b64u blake2s_160_file blake2s_160_file_hex blake2s_160_file_b64 blake2s_160_file_b64u )] );
11             our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
12             our @EXPORT = qw();
13              
14 2     2   10 use Carp;
  2         3  
  2         155  
15             $Carp::Internal{(__PACKAGE__)}++;
16 2     2   8 use Crypt::Digest;
  2         4  
  2         754  
17              
18             sub new {
19 21     21 1 7527 my ($class) = @_;
20 21         189 my $obj = Crypt::Digest->new('BLAKE2s_160');
21 21         194 return bless $obj, $class;
22             }
23              
24             sub clone {
25 3     3 1 1474 my ($self) = @_;
26 3         13 my $obj = Crypt::Digest::clone($self);
27 3   33     13 return bless $obj, ref($self) || $self;
28             }
29              
30 3     3 1 229303 sub hashsize { Crypt::Digest::hashsize('BLAKE2s_160') }
31 4     4 1 1013 sub blake2s_160 { Crypt::Digest::digest_data('BLAKE2s_160', @_) }
32 4     4 1 55 sub blake2s_160_hex { Crypt::Digest::digest_data_hex('BLAKE2s_160', @_) }
33 4     4 1 53 sub blake2s_160_b64 { Crypt::Digest::digest_data_b64('BLAKE2s_160', @_) }
34 1     1 1 17 sub blake2s_160_b64u { Crypt::Digest::digest_data_b64u('BLAKE2s_160', @_) }
35 4     4 1 23 sub blake2s_160_file { Crypt::Digest::digest_file('BLAKE2s_160', @_) }
36 4     4 1 22 sub blake2s_160_file_hex { Crypt::Digest::digest_file_hex('BLAKE2s_160', @_) }
37 4     4 1 20 sub blake2s_160_file_b64 { Crypt::Digest::digest_file_b64('BLAKE2s_160', @_) }
38 0     0 1   sub blake2s_160_file_b64u { Crypt::Digest::digest_file_b64u('BLAKE2s_160', @_) }
39              
40             1;
41              
42             =pod
43              
44             =head1 NAME
45              
46             Crypt::Digest::BLAKE2s_160 - Hash function BLAKE2s [size: 160 bits]
47              
48             =head1 SYNOPSIS
49              
50             ### Functional interface:
51             use Crypt::Digest::BLAKE2s_160 qw( blake2s_160 blake2s_160_hex blake2s_160_b64 blake2s_160_b64u
52             blake2s_160_file blake2s_160_file_hex blake2s_160_file_b64 blake2s_160_file_b64u );
53              
54             # calculate digest from string/buffer
55             my $data = 'data string';
56             my $blake2s_160_raw = blake2s_160($data);
57             my $blake2s_160_hex = blake2s_160_hex($data);
58             my $blake2s_160_b64 = blake2s_160_b64($data);
59             my $blake2s_160_b64u = blake2s_160_b64u($data);
60             # or from file
61             my $blake2s_160_file_raw = blake2s_160_file('filename.dat');
62             my $blake2s_160_file_hex = blake2s_160_file_hex('filename.dat');
63             my $blake2s_160_file_b64 = blake2s_160_file_b64('filename.dat');
64             my $blake2s_160_file_b64u = blake2s_160_file_b64u('filename.dat');
65             # or from filehandle
66             my $filehandle = ...; # existing binary-mode filehandle
67             my $blake2s_160_fh_raw = blake2s_160_file($filehandle);
68             my $blake2s_160_fh_hex = blake2s_160_file_hex($filehandle);
69             my $blake2s_160_fh_b64 = blake2s_160_file_b64($filehandle);
70             my $blake2s_160_fh_b64u = blake2s_160_file_b64u($filehandle);
71              
72             ### OO interface:
73             use Crypt::Digest::BLAKE2s_160;
74              
75             my $d = Crypt::Digest::BLAKE2s_160->new;
76             $d->add('any data');
77             my $result_raw = $d->digest; # raw bytes
78             my $result_hex = $d->hexdigest; # hexadecimal form
79             my $result_b64 = $d->b64digest; # Base64 form
80             my $result_b64u = $d->b64udigest; # Base64 URL-safe form
81              
82             # or hash a file instead
83             my $file_result_raw = Crypt::Digest::BLAKE2s_160->new->addfile('filename.dat')->digest;
84              
85             =head1 DESCRIPTION
86              
87             I
88              
89             Provides an interface to the BLAKE2s_160 digest algorithm.
90              
91             =head1 EXPORT
92              
93             Nothing is exported by default.
94              
95             You can export selected functions:
96              
97             use Crypt::Digest::BLAKE2s_160 qw(blake2s_160 blake2s_160_hex blake2s_160_b64 blake2s_160_b64u
98             blake2s_160_file blake2s_160_file_hex blake2s_160_file_b64 blake2s_160_file_b64u);
99              
100             Or all of them at once:
101              
102             use Crypt::Digest::BLAKE2s_160 ':all';
103              
104             =head1 FUNCTIONS
105              
106             =head2 blake2s_160
107              
108             Joins all arguments into a single string and returns its BLAKE2s_160 digest encoded as a binary string.
109              
110             Data arguments for the functional helpers are converted to byte strings using
111             Perl's usual scalar stringification. Defined scalars, including numbers and
112             string-overloaded objects, are accepted. C is treated as an empty
113             string and may emit Perl's usual "uninitialized value" warning. The same
114             rules apply to C, C, and
115             C.
116              
117             my $blake2s_160_raw = blake2s_160('data string');
118             #or
119             my $blake2s_160_raw = blake2s_160('any data', 'more data', 'even more data');
120              
121             =head2 blake2s_160_hex
122              
123             Joins all arguments into a single string and returns its BLAKE2s_160 digest encoded as a hexadecimal string.
124              
125             my $blake2s_160_hex = blake2s_160_hex('data string');
126             #or
127             my $blake2s_160_hex = blake2s_160_hex('any data', 'more data', 'even more data');
128              
129             =head2 blake2s_160_b64
130              
131             Joins all arguments into a single string and returns its BLAKE2s_160 digest encoded as a Base64 string, B trailing '=' padding.
132              
133             my $blake2s_160_b64 = blake2s_160_b64('data string');
134             #or
135             my $blake2s_160_b64 = blake2s_160_b64('any data', 'more data', 'even more data');
136              
137             =head2 blake2s_160_b64u
138              
139             Joins all arguments into a single string and returns its BLAKE2s_160 digest encoded as a Base64 URL-safe string (see RFC 4648 section 5).
140              
141             my $blake2s_160_b64url = blake2s_160_b64u('data string');
142             #or
143             my $blake2s_160_b64url = blake2s_160_b64u('any data', 'more data', 'even more data');
144              
145             =head2 blake2s_160_file
146              
147             Reads a file given by a filename or filehandle and returns its BLAKE2s_160 digest encoded as a binary string.
148              
149             my $blake2s_160_raw = blake2s_160_file('filename.dat');
150             #or
151             my $filehandle = ...; # existing binary-mode filehandle
152             my $blake2s_160_raw = blake2s_160_file($filehandle);
153              
154             =head2 blake2s_160_file_hex
155              
156             Reads a file given by a filename or filehandle and returns its BLAKE2s_160 digest encoded as a hexadecimal string.
157              
158             my $blake2s_160_hex = blake2s_160_file_hex('filename.dat');
159             #or
160             my $filehandle = ...; # existing binary-mode filehandle
161             my $blake2s_160_hex = blake2s_160_file_hex($filehandle);
162              
163             B The filehandle must be in binary mode before you pass it to C.
164              
165             =head2 blake2s_160_file_b64
166              
167             Reads a file given by a filename or filehandle and returns its BLAKE2s_160 digest encoded as a Base64 string, B trailing '=' padding.
168              
169             my $blake2s_160_b64 = blake2s_160_file_b64('filename.dat');
170             #or
171             my $filehandle = ...; # existing binary-mode filehandle
172             my $blake2s_160_b64 = blake2s_160_file_b64($filehandle);
173              
174             =head2 blake2s_160_file_b64u
175              
176             Reads a file given by a filename or filehandle and returns its BLAKE2s_160 digest encoded as a Base64 URL-safe string (see RFC 4648 section 5).
177              
178             my $blake2s_160_b64url = blake2s_160_file_b64u('filename.dat');
179             #or
180             my $filehandle = ...; # existing binary-mode filehandle
181             my $blake2s_160_b64url = blake2s_160_file_b64u($filehandle);
182              
183             =head1 METHODS
184              
185             The OO interface provides the same set of functions as L.
186             Unless noted otherwise, assume C<$d> is an existing digest object created via
187             C, for example:
188              
189             my $d = Crypt::Digest::BLAKE2s_160->new();
190              
191             =head2 new
192              
193             my $d = Crypt::Digest::BLAKE2s_160->new();
194              
195             =head2 clone
196              
197             $d->clone();
198              
199             =head2 reset
200              
201             $d->reset();
202              
203             =head2 add
204              
205             Appends data to the message. Returns the object itself (for chaining).
206              
207             Each argument is converted to bytes using Perl's usual scalar stringification.
208             Defined scalars, including numbers and string-overloaded objects, are
209             accepted. C is treated as an empty string and may emit Perl's usual
210             "uninitialized value" warning.
211              
212             $d->add('any data');
213             #or
214             $d->add('any data', 'more data', 'even more data');
215              
216             =head2 addfile
217              
218             Reads the file content and appends it to the message. Returns the object itself (for chaining).
219              
220             $d->addfile('filename.dat');
221             #or
222             my $filehandle = ...; # existing binary-mode filehandle
223             $d->addfile($filehandle);
224              
225             =head2 hashsize
226              
227             $d->hashsize;
228             #or
229             Crypt::Digest::BLAKE2s_160->hashsize();
230             #or
231             Crypt::Digest::BLAKE2s_160::hashsize();
232              
233             =head2 digest
234              
235             Returns the binary digest (raw bytes).
236             The first call finalizes the digest object. Any later C,
237             C, C, C, C, or
238             C call will fail until you call C.
239              
240             my $result_raw = $d->digest();
241              
242             =head2 hexdigest
243              
244             Returns the digest encoded as a lowercase hexadecimal string.
245             Like C, the first call finalizes the digest object.
246              
247             my $result_hex = $d->hexdigest();
248              
249             =head2 b64digest
250              
251             Returns the digest encoded as a Base64 string with trailing C<=> padding.
252             Like C, the first call finalizes the digest object.
253              
254             my $result_b64 = $d->b64digest();
255              
256             =head2 b64udigest
257              
258             Returns the digest encoded as a Base64 URL-safe string (no trailing C<=>).
259             Like C, the first call finalizes the digest object.
260              
261             my $result_b64url = $d->b64udigest();
262              
263             =head1 SEE ALSO
264              
265             =over
266              
267             =item * L, L
268              
269             =item * L
270              
271             =item * L
272              
273             =back
274              
275             =cut