1Digest::HMAC(3)       User Contributed Perl Documentation      Digest::HMAC(3)
2
3
4

NAME

6       Digest::HMAC - Keyed-Hashing for Message Authentication
7

SYNOPSIS

9        # Functional style
10        use Digest::HMAC qw(hmac hmac_hex);
11        $digest = hmac($data, $key, \&myhash);
12        print hmac_hex($data, $key, \&myhash);
13
14        # OO style
15        use Digest::HMAC;
16        $hmac = Digest::HMAC->new($key, "Digest::MyHash");
17
18        $hmac->add($data);
19        $hmac->addfile(*FILE);
20
21        $digest = $hmac->digest;
22        $digest = $hmac->hexdigest;
23        $digest = $hmac->b64digest;
24

DESCRIPTION

26       HMAC is used for message integrity checks between two parties that
27       share a secret key, and works in combination with some other Digest
28       algorithm, usually MD5 or SHA-1.  The HMAC mechanism is described in
29       RFC 2104.
30
31       HMAC follow the common "Digest::" interface, but the constructor takes
32       the secret key and the name of some other simple "Digest::" as
33       argument.
34
35       The hmac() and hmac_hex() functions and the Digest::HMAC->new()
36       constructor takes an optional $blocksize argument as well.  The HMAC
37       algorithm assumes the digester to hash by iterating a basic compression
38       function on blocks of data and the $blocksize should match the byte-
39       length of such blocks.
40
41       The default $blocksize is 64 which is suitable for the MD5 and SHA-1
42       digest functions.  For stronger algorithms the blocksize probably needs
43       to be increased.
44

SEE ALSO

46       Digest::HMAC_MD5, Digest::HMAC_SHA1
47
48       RFC 2104
49

AUTHORS

51       Graham Barr <gbarr@ti.com>, Gisle Aas <gisle@aas.no>
52
53
54
55perl v5.30.0                      2019-07-26                   Digest::HMAC(3)
Impressum