blib/lib/Crypt/Digest/SHA3_224.pm

filter: Statementstmt 97.3% 36 / 37 Branchbran n/a Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 93.7% 15 / 16 Podpod 100% 11 / 11 totaltotal 91.3% 63 / 69 CC 2 SCAR 1.8
CC
2
Cov
92%
clone
2.1
sha3_224_file_b64u
2.0
BEGIN
1.0
CRAP 1.2
« blib/lib/Crypt/Digest/SHA384.pm ↑ Summary blib/lib/Crypt/Digest/SHA3_256.pm »
1 package Crypt::Digest::SHA3_224;
2  
3 ### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
4  
5 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 our $VERSION = '0.091';
8  
9 2 ▶use base qw(Crypt::Digest Exporter);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 our %EXPORT_TAGS = ( all => [qw( sha3_224 sha3_224_hex sha3_224_b64 sha3_224_b64u sha3_224_file sha3_224_file_hex sha3_224_file_b64 sha3_224_file_b64u )] );
11 2 our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
12 2 our @EXPORT = qw();
13  
14 2 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 2 $Carp::Internal{(__PACKAGE__)}++;
16 2 ▶use Crypt::Digest;
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 21 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
19 21 my ($class) = @_;
20 21 my $obj = Crypt::Digest->new('SHA3_224');
21 21 return bless $obj, $class;
22 }
23  
24 3 ▶sub clone {
Subroutine clone: called CC=2 SCAR=7.6
Pod documented
25 3 my ($self) = @_;
26 3 my $obj = Crypt::Digest::clone($self);
27 3 ▶ return bless $obj, ref($self) || $self;
Condition33%1/3
ref $self || $self
l!l&&r!l&&!r
300
MC/DC0%0/2
ref $self || $self
ref $self $self
Truth table33%1/3
A || B
A= ref $selfB= $self
ABresult
1X1
011
000
28 }
29  
30 3 ▶sub hashsize { Crypt::Digest::hashsize('SHA3_224') }
Subroutine hashsize: called CC=1 SCAR=0.0
Pod documented
31 4 ▶sub sha3_224 { Crypt::Digest::digest_data('SHA3_224', @_) }
Subroutine sha3_224: called CC=1 SCAR=0.0
Pod documented
32 4 ▶sub sha3_224_hex { Crypt::Digest::digest_data_hex('SHA3_224', @_) }
Subroutine sha3_224_hex: called CC=1 SCAR=0.0
Pod documented
33 4 ▶sub sha3_224_b64 { Crypt::Digest::digest_data_b64('SHA3_224', @_) }
Subroutine sha3_224_b64: called CC=1 SCAR=0.0
Pod documented
34 1 ▶sub sha3_224_b64u { Crypt::Digest::digest_data_b64u('SHA3_224', @_) }
Subroutine sha3_224_b64u: called CC=1 SCAR=0.0
Pod documented
35 4 ▶sub sha3_224_file { Crypt::Digest::digest_file('SHA3_224', @_) }
Subroutine sha3_224_file: called CC=1 SCAR=0.0
Pod documented
36 4 ▶sub sha3_224_file_hex { Crypt::Digest::digest_file_hex('SHA3_224', @_) }
Subroutine sha3_224_file_hex: called CC=1 SCAR=0.0
Pod documented
37 4 ▶sub sha3_224_file_b64 { Crypt::Digest::digest_file_b64('SHA3_224', @_) }
Subroutine sha3_224_file_b64: called CC=1 SCAR=0.0
Pod documented
38 0 ▶sub sha3_224_file_b64u { Crypt::Digest::digest_file_b64u('SHA3_224', @_) }
Subroutine sha3_224_file_b64u: not called CC=1 SCAR=6.9
Pod documented
39  
40 2 1;
41  
42 =pod
43  
44 =head1 NAME
45  
46 Crypt::Digest::SHA3_224 - Hash function SHA3-224 [size: 224 bits]
47  
48 =head1 SYNOPSIS
49  
50 ### Functional interface:
51 use Crypt::Digest::SHA3_224 qw( sha3_224 sha3_224_hex sha3_224_b64 sha3_224_b64u
52 sha3_224_file sha3_224_file_hex sha3_224_file_b64 sha3_224_file_b64u );
53  
54 # calculate digest from string/buffer
55 my $data = 'data string';
56 my $sha3_224_raw = sha3_224($data);
57 my $sha3_224_hex = sha3_224_hex($data);
58 my $sha3_224_b64 = sha3_224_b64($data);
59 my $sha3_224_b64u = sha3_224_b64u($data);
60 # or from file
61 my $sha3_224_file_raw = sha3_224_file('filename.dat');
62 my $sha3_224_file_hex = sha3_224_file_hex('filename.dat');
63 my $sha3_224_file_b64 = sha3_224_file_b64('filename.dat');
64 my $sha3_224_file_b64u = sha3_224_file_b64u('filename.dat');
65 # or from filehandle
66 my $filehandle = ...; # existing binary-mode filehandle
67 my $sha3_224_fh_raw = sha3_224_file($filehandle);
68 my $sha3_224_fh_hex = sha3_224_file_hex($filehandle);
69 my $sha3_224_fh_b64 = sha3_224_file_b64($filehandle);
70 my $sha3_224_fh_b64u = sha3_224_file_b64u($filehandle);
71  
72 ### OO interface:
73 use Crypt::Digest::SHA3_224;
74  
75 my $d = Crypt::Digest::SHA3_224->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::SHA3_224->new->addfile('filename.dat')->digest;
84  
85 =head1 DESCRIPTION
86  
87 I<Since: CryptX-0.048>
88  
89 Provides an interface to the SHA3_224 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::SHA3_224 qw(sha3_224 sha3_224_hex sha3_224_b64 sha3_224_b64u
98 sha3_224_file sha3_224_file_hex sha3_224_file_b64 sha3_224_file_b64u);
99  
100 Or all of them at once:
101  
102 use Crypt::Digest::SHA3_224 ':all';
103  
104 =head1 FUNCTIONS
105  
106 =head2 sha3_224
107  
108 Joins all arguments into a single string and returns its SHA3_224 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<undef> is treated as an empty
113 string and may emit Perl's usual "uninitialized value" warning. The same
114 rules apply to C<sha3_224_hex>, C<sha3_224_b64>, and
115 C<sha3_224_b64u>.
116  
117 my $sha3_224_raw = sha3_224('data string');
118 #or
119 my $sha3_224_raw = sha3_224('any data', 'more data', 'even more data');
120  
121 =head2 sha3_224_hex
122  
123 Joins all arguments into a single string and returns its SHA3_224 digest encoded as a hexadecimal string.
124  
125 my $sha3_224_hex = sha3_224_hex('data string');
126 #or
127 my $sha3_224_hex = sha3_224_hex('any data', 'more data', 'even more data');
128  
129 =head2 sha3_224_b64
130  
131 Joins all arguments into a single string and returns its SHA3_224 digest encoded as a Base64 string, B<with> trailing '=' padding.
132  
133 my $sha3_224_b64 = sha3_224_b64('data string');
134 #or
135 my $sha3_224_b64 = sha3_224_b64('any data', 'more data', 'even more data');
136  
137 =head2 sha3_224_b64u
138  
139 Joins all arguments into a single string and returns its SHA3_224 digest encoded as a Base64 URL-safe string (see RFC 4648 section 5).
140  
141 my $sha3_224_b64url = sha3_224_b64u('data string');
142 #or
143 my $sha3_224_b64url = sha3_224_b64u('any data', 'more data', 'even more data');
144  
145 =head2 sha3_224_file
146  
147 Reads a file given by a filename or filehandle and returns its SHA3_224 digest encoded as a binary string.
148  
149 my $sha3_224_raw = sha3_224_file('filename.dat');
150 #or
151 my $filehandle = ...; # existing binary-mode filehandle
152 my $sha3_224_raw = sha3_224_file($filehandle);
153  
154 =head2 sha3_224_file_hex
155  
156 Reads a file given by a filename or filehandle and returns its SHA3_224 digest encoded as a hexadecimal string.
157  
158 my $sha3_224_hex = sha3_224_file_hex('filename.dat');
159 #or
160 my $filehandle = ...; # existing binary-mode filehandle
161 my $sha3_224_hex = sha3_224_file_hex($filehandle);
162  
163 B<Note:> The filehandle must be in binary mode before you pass it to C<addfile()>.
164  
165 =head2 sha3_224_file_b64
166  
167 Reads a file given by a filename or filehandle and returns its SHA3_224 digest encoded as a Base64 string, B<with> trailing '=' padding.
168  
169 my $sha3_224_b64 = sha3_224_file_b64('filename.dat');
170 #or
171 my $filehandle = ...; # existing binary-mode filehandle
172 my $sha3_224_b64 = sha3_224_file_b64($filehandle);
173  
174 =head2 sha3_224_file_b64u
175  
176 Reads a file given by a filename or filehandle and returns its SHA3_224 digest encoded as a Base64 URL-safe string (see RFC 4648 section 5).
177  
178 my $sha3_224_b64url = sha3_224_file_b64u('filename.dat');
179 #or
180 my $filehandle = ...; # existing binary-mode filehandle
181 my $sha3_224_b64url = sha3_224_file_b64u($filehandle);
182  
183 =head1 METHODS
184  
185 The OO interface provides the same set of functions as L<Crypt::Digest>.
186 Unless noted otherwise, assume C<$d> is an existing digest object created via
187 C<new>, for example:
188  
189 my $d = Crypt::Digest::SHA3_224->new();
190  
191 =head2 new
192  
193 my $d = Crypt::Digest::SHA3_224->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<undef> 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::SHA3_224->hashsize();
230 #or
231 Crypt::Digest::SHA3_224::hashsize();
232  
233 =head2 digest
234  
235 Returns the binary digest (raw bytes).
236 The first call finalizes the digest object. Any later C<add()>,
237 C<addfile()>, C<digest()>, C<hexdigest()>, C<b64digest()>, or
238 C<b64udigest()> call will fail until you call C<reset()>.
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<digest()>, 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<digest()>, 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<digest()>, 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<CryptX>, L<Crypt::Digest>
268  
269 =item * L<https://en.wikipedia.org/wiki/SHA-3>
270  
271 =back
272  
273 =cut
« blib/lib/Crypt/Digest/SHA384.pm ↑ Summary blib/lib/Crypt/Digest/SHA3_256.pm »