| 1 | package Crypt::Digest::BLAKE2s_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( blake2s_224 blake2s_224_hex blake2s_224_b64 blake2s_224_b64u blake2s_224_file blake2s_224_file_hex blake2s_224_file_b64 blake2s_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('BLAKE2s_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
MC/DC0%0/2
ref $self || $self
ref $self
$self
Truth table33%1/3
A || B
A= ref $selfB= $self
| |||||||||||||||||||||
| 28 | } | ||||||||||||||||||||
| 29 | |||||||||||||||||||||
| 30 | 3 | ▶ | sub hashsize { Crypt::Digest::hashsize('BLAKE2s_224') } | ||||||||||||||||||
|
Subroutine
hashsize: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 31 | 4 | ▶ | sub blake2s_224 { Crypt::Digest::digest_data('BLAKE2s_224', @_) } | ||||||||||||||||||
|
Subroutine
blake2s_224: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 32 | 4 | ▶ | sub blake2s_224_hex { Crypt::Digest::digest_data_hex('BLAKE2s_224', @_) } | ||||||||||||||||||
|
Subroutine
blake2s_224_hex: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 33 | 4 | ▶ | sub blake2s_224_b64 { Crypt::Digest::digest_data_b64('BLAKE2s_224', @_) } | ||||||||||||||||||
|
Subroutine
blake2s_224_b64: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 34 | 1 | ▶ | sub blake2s_224_b64u { Crypt::Digest::digest_data_b64u('BLAKE2s_224', @_) } | ||||||||||||||||||
|
Subroutine
blake2s_224_b64u: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 35 | 4 | ▶ | sub blake2s_224_file { Crypt::Digest::digest_file('BLAKE2s_224', @_) } | ||||||||||||||||||
|
Subroutine
blake2s_224_file: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 36 | 4 | ▶ | sub blake2s_224_file_hex { Crypt::Digest::digest_file_hex('BLAKE2s_224', @_) } | ||||||||||||||||||
|
Subroutine
blake2s_224_file_hex: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 37 | 4 | ▶ | sub blake2s_224_file_b64 { Crypt::Digest::digest_file_b64('BLAKE2s_224', @_) } | ||||||||||||||||||
|
Subroutine
blake2s_224_file_b64: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 38 | 0 | ▶ | sub blake2s_224_file_b64u { Crypt::Digest::digest_file_b64u('BLAKE2s_224', @_) } | ||||||||||||||||||
|
Subroutine
blake2s_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::BLAKE2s_224 - Hash function BLAKE2s [size: 224 bits] | ||||||||||||||||||||
| 47 | |||||||||||||||||||||
| 48 | =head1 SYNOPSIS | ||||||||||||||||||||
| 49 | |||||||||||||||||||||
| 50 | ### Functional interface: | ||||||||||||||||||||
| 51 | use Crypt::Digest::BLAKE2s_224 qw( blake2s_224 blake2s_224_hex blake2s_224_b64 blake2s_224_b64u | ||||||||||||||||||||
| 52 | blake2s_224_file blake2s_224_file_hex blake2s_224_file_b64 blake2s_224_file_b64u ); | ||||||||||||||||||||
| 53 | |||||||||||||||||||||
| 54 | # calculate digest from string/buffer | ||||||||||||||||||||
| 55 | my $data = 'data string'; | ||||||||||||||||||||
| 56 | my $blake2s_224_raw = blake2s_224($data); | ||||||||||||||||||||
| 57 | my $blake2s_224_hex = blake2s_224_hex($data); | ||||||||||||||||||||
| 58 | my $blake2s_224_b64 = blake2s_224_b64($data); | ||||||||||||||||||||
| 59 | my $blake2s_224_b64u = blake2s_224_b64u($data); | ||||||||||||||||||||
| 60 | # or from file | ||||||||||||||||||||
| 61 | my $blake2s_224_file_raw = blake2s_224_file('filename.dat'); | ||||||||||||||||||||
| 62 | my $blake2s_224_file_hex = blake2s_224_file_hex('filename.dat'); | ||||||||||||||||||||
| 63 | my $blake2s_224_file_b64 = blake2s_224_file_b64('filename.dat'); | ||||||||||||||||||||
| 64 | my $blake2s_224_file_b64u = blake2s_224_file_b64u('filename.dat'); | ||||||||||||||||||||
| 65 | # or from filehandle | ||||||||||||||||||||
| 66 | my $filehandle = ...; # existing binary-mode filehandle | ||||||||||||||||||||
| 67 | my $blake2s_224_fh_raw = blake2s_224_file($filehandle); | ||||||||||||||||||||
| 68 | my $blake2s_224_fh_hex = blake2s_224_file_hex($filehandle); | ||||||||||||||||||||
| 69 | my $blake2s_224_fh_b64 = blake2s_224_file_b64($filehandle); | ||||||||||||||||||||
| 70 | my $blake2s_224_fh_b64u = blake2s_224_file_b64u($filehandle); | ||||||||||||||||||||
| 71 | |||||||||||||||||||||
| 72 | ### OO interface: | ||||||||||||||||||||
| 73 | use Crypt::Digest::BLAKE2s_224; | ||||||||||||||||||||
| 74 | |||||||||||||||||||||
| 75 | my $d = Crypt::Digest::BLAKE2s_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::BLAKE2s_224->new->addfile('filename.dat')->digest; | ||||||||||||||||||||
| 84 | |||||||||||||||||||||
| 85 | =head1 DESCRIPTION | ||||||||||||||||||||
| 86 | |||||||||||||||||||||
| 87 | I<Since: CryptX-0.048> | ||||||||||||||||||||
| 88 | |||||||||||||||||||||
| 89 | Provides an interface to the BLAKE2s_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::BLAKE2s_224 qw(blake2s_224 blake2s_224_hex blake2s_224_b64 blake2s_224_b64u | ||||||||||||||||||||
| 98 | blake2s_224_file blake2s_224_file_hex blake2s_224_file_b64 blake2s_224_file_b64u); | ||||||||||||||||||||
| 99 | |||||||||||||||||||||
| 100 | Or all of them at once: | ||||||||||||||||||||
| 101 | |||||||||||||||||||||
| 102 | use Crypt::Digest::BLAKE2s_224 ':all'; | ||||||||||||||||||||
| 103 | |||||||||||||||||||||
| 104 | =head1 FUNCTIONS | ||||||||||||||||||||
| 105 | |||||||||||||||||||||
| 106 | =head2 blake2s_224 | ||||||||||||||||||||
| 107 | |||||||||||||||||||||
| 108 | Joins all arguments into a single string and returns its BLAKE2s_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<blake2s_224_hex>, C<blake2s_224_b64>, and | ||||||||||||||||||||
| 115 | C<blake2s_224_b64u>. | ||||||||||||||||||||
| 116 | |||||||||||||||||||||
| 117 | my $blake2s_224_raw = blake2s_224('data string'); | ||||||||||||||||||||
| 118 | #or | ||||||||||||||||||||
| 119 | my $blake2s_224_raw = blake2s_224('any data', 'more data', 'even more data'); | ||||||||||||||||||||
| 120 | |||||||||||||||||||||
| 121 | =head2 blake2s_224_hex | ||||||||||||||||||||
| 122 | |||||||||||||||||||||
| 123 | Joins all arguments into a single string and returns its BLAKE2s_224 digest encoded as a hexadecimal string. | ||||||||||||||||||||
| 124 | |||||||||||||||||||||
| 125 | my $blake2s_224_hex = blake2s_224_hex('data string'); | ||||||||||||||||||||
| 126 | #or | ||||||||||||||||||||
| 127 | my $blake2s_224_hex = blake2s_224_hex('any data', 'more data', 'even more data'); | ||||||||||||||||||||
| 128 | |||||||||||||||||||||
| 129 | =head2 blake2s_224_b64 | ||||||||||||||||||||
| 130 | |||||||||||||||||||||
| 131 | Joins all arguments into a single string and returns its BLAKE2s_224 digest encoded as a Base64 string, B<with> trailing '=' padding. | ||||||||||||||||||||
| 132 | |||||||||||||||||||||
| 133 | my $blake2s_224_b64 = blake2s_224_b64('data string'); | ||||||||||||||||||||
| 134 | #or | ||||||||||||||||||||
| 135 | my $blake2s_224_b64 = blake2s_224_b64('any data', 'more data', 'even more data'); | ||||||||||||||||||||
| 136 | |||||||||||||||||||||
| 137 | =head2 blake2s_224_b64u | ||||||||||||||||||||
| 138 | |||||||||||||||||||||
| 139 | Joins all arguments into a single string and returns its BLAKE2s_224 digest encoded as a Base64 URL-safe string (see RFC 4648 section 5). | ||||||||||||||||||||
| 140 | |||||||||||||||||||||
| 141 | my $blake2s_224_b64url = blake2s_224_b64u('data string'); | ||||||||||||||||||||
| 142 | #or | ||||||||||||||||||||
| 143 | my $blake2s_224_b64url = blake2s_224_b64u('any data', 'more data', 'even more data'); | ||||||||||||||||||||
| 144 | |||||||||||||||||||||
| 145 | =head2 blake2s_224_file | ||||||||||||||||||||
| 146 | |||||||||||||||||||||
| 147 | Reads a file given by a filename or filehandle and returns its BLAKE2s_224 digest encoded as a binary string. | ||||||||||||||||||||
| 148 | |||||||||||||||||||||
| 149 | my $blake2s_224_raw = blake2s_224_file('filename.dat'); | ||||||||||||||||||||
| 150 | #or | ||||||||||||||||||||
| 151 | my $filehandle = ...; # existing binary-mode filehandle | ||||||||||||||||||||
| 152 | my $blake2s_224_raw = blake2s_224_file($filehandle); | ||||||||||||||||||||
| 153 | |||||||||||||||||||||
| 154 | =head2 blake2s_224_file_hex | ||||||||||||||||||||
| 155 | |||||||||||||||||||||
| 156 | Reads a file given by a filename or filehandle and returns its BLAKE2s_224 digest encoded as a hexadecimal string. | ||||||||||||||||||||
| 157 | |||||||||||||||||||||
| 158 | my $blake2s_224_hex = blake2s_224_file_hex('filename.dat'); | ||||||||||||||||||||
| 159 | #or | ||||||||||||||||||||
| 160 | my $filehandle = ...; # existing binary-mode filehandle | ||||||||||||||||||||
| 161 | my $blake2s_224_hex = blake2s_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 blake2s_224_file_b64 | ||||||||||||||||||||
| 166 | |||||||||||||||||||||
| 167 | Reads a file given by a filename or filehandle and returns its BLAKE2s_224 digest encoded as a Base64 string, B<with> trailing '=' padding. | ||||||||||||||||||||
| 168 | |||||||||||||||||||||
| 169 | my $blake2s_224_b64 = blake2s_224_file_b64('filename.dat'); | ||||||||||||||||||||
| 170 | #or | ||||||||||||||||||||
| 171 | my $filehandle = ...; # existing binary-mode filehandle | ||||||||||||||||||||
| 172 | my $blake2s_224_b64 = blake2s_224_file_b64($filehandle); | ||||||||||||||||||||
| 173 | |||||||||||||||||||||
| 174 | =head2 blake2s_224_file_b64u | ||||||||||||||||||||
| 175 | |||||||||||||||||||||
| 176 | Reads a file given by a filename or filehandle and returns its BLAKE2s_224 digest encoded as a Base64 URL-safe string (see RFC 4648 section 5). | ||||||||||||||||||||
| 177 | |||||||||||||||||||||
| 178 | my $blake2s_224_b64url = blake2s_224_file_b64u('filename.dat'); | ||||||||||||||||||||
| 179 | #or | ||||||||||||||||||||
| 180 | my $filehandle = ...; # existing binary-mode filehandle | ||||||||||||||||||||
| 181 | my $blake2s_224_b64url = blake2s_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::BLAKE2s_224->new(); | ||||||||||||||||||||
| 190 | |||||||||||||||||||||
| 191 | =head2 new | ||||||||||||||||||||
| 192 | |||||||||||||||||||||
| 193 | my $d = Crypt::Digest::BLAKE2s_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::BLAKE2s_224->hashsize(); | ||||||||||||||||||||
| 230 | #or | ||||||||||||||||||||
| 231 | Crypt::Digest::BLAKE2s_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://blake2.net/> | ||||||||||||||||||||
| 270 | |||||||||||||||||||||
| 271 | =item * L<https://www.rfc-editor.org/rfc/rfc7693> | ||||||||||||||||||||
| 272 | |||||||||||||||||||||
| 273 | =back | ||||||||||||||||||||
| 274 | |||||||||||||||||||||
| 275 | =cut | ||||||||||||||||||||