Crypt::...:BLAKE2s(3)

πŸ’– NAME πŸ’–

Crypt::Mac::BLAKE2s β€” Message authentication code BLAKE2s MAC (RFC 7693)

Okay bestie, this is the User Contributed Perl Documentation manual for Crypt::Mac::BLAKE2s, and it is here to give you the BLAKE2s MAC interface. RFC 7693 coded, periodt. ✨

✨ SYNOPSIS ✨

First up, the functional interface:

### Functional interface:
use Crypt::Mac::BLAKE2s qw( blake2s blake2s_hex blake2s_b64 blake2s_b64u );

# calculate MAC from string/buffer
my $blake2s_raw  = blake2s($size, $key, 'data buffer');
my $blake2s_hex  = blake2s_hex($size, $key, 'data buffer');
my $blake2s_b64  = blake2s_b64($size, $key, 'data buffer');
my $blake2s_b64u = blake2s_b64u($size, $key, 'data buffer');

And then the OO interface:

### OO interface:
use Crypt::Mac::BLAKE2s;

my $d = Crypt::Mac::BLAKE2s->new($size, $key);
$d->add('any data');
my $result_hex = $d->hexmac;   # finalizes the object

# for another output encoding use a fresh object (or clone before finalizing)
my $result_b64u = Crypt::Mac::BLAKE2s->new($size, $key)->add('any data')->b64umac;

# or MAC a file instead
my $file_result_raw = Crypt::Mac::BLAKE2s->new($size, $key)->addfile('filename.dat')->mac;

🌸 DESCRIPTION 🌸

Provides an interface to the BLAKE2s message authentication code (MAC) algorithm. That's the whole vibe check, bestie: BLAKE2s MAC, but as a Perl module. πŸ’…

πŸŽ€ EXPORT πŸŽ€

Nothing is exported by default. Not even one little function. But you can export selected functions like this:

use Crypt::Mac::BLAKE2s qw( blake2s blake2s_hex blake2s_b64 blake2s_b64u );

Or go full main character and grab all of them at once:

use Crypt::Mac::BLAKE2s ':all';

πŸ”₯ FUNCTIONS πŸ”₯

blake2s

Joins all arguments into a single string and returns its BLAKE2s message authentication code encoded as a binary string.

Data arguments for the functional helpers are converted to byte strings using Perl's usual scalar stringification. Defined scalars, including numbers and string-overloaded objects, are accepted. undef is treated as an empty string and may emit Perl's usual "uninitialized value" warning. The same rules apply to blake2s_hex, blake2s_b64, and blake2s_b64u. Iykyk.

my $blake2s_raw = blake2s($size, $key, 'data buffer');
#or
my $blake2s_raw = blake2s($size, $key, 'any data', 'more data', 'even more data');

blake2s_hex

Joins all arguments into a single string and returns its BLAKE2s message authentication code encoded as a hexadecimal string.

my $blake2s_hex = blake2s_hex($size, $key, 'data buffer');
#or
my $blake2s_hex = blake2s_hex($size, $key, 'any data', 'more data', 'even more data');

blake2s_b64

Joins all arguments into a single string and returns its BLAKE2s message authentication code encoded as a Base64 string.

my $blake2s_b64 = blake2s_b64($size, $key, 'data buffer');
#or
my $blake2s_b64 = blake2s_b64($size, $key, 'any data', 'more data', 'even more data');

blake2s_b64u

Joins all arguments into a single string and returns its BLAKE2s message authentication code encoded as a Base64 URL-safe string (see RFC 4648 section 5).

my $blake2s_b64url = blake2s_b64u($size, $key, 'data buffer');
#or
my $blake2s_b64url = blake2s_b64u($size, $key, 'any data', 'more data', 'even more data');

πŸ’… METHODS πŸ’…

Unless noted otherwise, assume $d is an existing MAC object created via new, for example:

my $d = Crypt::Mac::BLAKE2s->new($size, $key);

new

my $d = Crypt::Mac::BLAKE2s->new($size, $key);

# $size .. [integer] desired MAC output size in bytes (1 - 32)
# $key ... [binary string] the key (1 - 32 bytes)

clone

The clone call is giving copy era:

$d->clone();

add

Appends data to the message. Returns the object itself (for chaining). Croaks if the object has already been finalized by mac, hexmac, b64mac, or b64umac. No take-backs after finalizing, bestie.

Each argument is converted to bytes using Perl's usual scalar stringification. Defined scalars, including numbers and string-overloaded objects, are accepted. undef is treated as an empty string and may emit Perl's usual "uninitialized value" warning.

$d->add('any data');
#or
$d->add('any data', 'more data', 'even more data');

addfile

Reads the file content and appends it to the message. Returns the object itself (for chaining). Croaks if the object has already been finalized by mac, hexmac, b64mac, or b64umac.

$d->addfile('filename.dat');
#or
my $filehandle = ...; # existing binary-mode filehandle
$d->addfile($filehandle);

mac

Returns the binary MAC (raw bytes) and finalizes the object. After the first call to mac, hexmac, b64mac, or b64umac, later calls to add, addfile, or any MAC getter croak.

my $result_raw = $d->mac();

hexmac

Returns the MAC encoded as a lowercase hexadecimal string and finalizes the object. After the first call to mac, hexmac, b64mac, or b64umac, later calls to add, addfile, or any MAC getter croak.

my $result_hex = $d->hexmac();

b64mac

Returns the MAC encoded as a Base64 string with trailing = padding and finalizes the object. After the first call to mac, hexmac, b64mac, or b64umac, later calls to add, addfile, or any MAC getter croak.

my $result_b64 = $d->b64mac();

b64umac

Returns the MAC encoded as a Base64 URL-safe string (no trailing =) and finalizes the object. After the first call to mac, hexmac, b64mac, or b64umac, later calls to add, addfile, or any MAC getter croak.

my $result_b64url = $d->b64umac();

πŸ¦‹ SEE ALSO πŸ¦‹


Alright bestie, that's the whole page. Mwah πŸ’‹ β€” this one is from perl v5.42.0, dated 2026-05-11, and the footer manual name is Crypt::...:BLAKE2s(3). Slay and stay hashy. πŸŽ€βœ¨

πŸ“¦ where this page comes from