File Coverage

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