{
    "mode": "perldoc",
    "parameter": "Digest::HMAC",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/Digest%3A%3AHMAC/json",
    "generated": "2026-06-11T04:11:29Z",
    "synopsis": "# Functional style\nuse Digest::HMAC qw(hmac hmachex);\n$digest = hmac($data, $key, \\&myhash);\nprint hmachex($data, $key, \\&myhash);\n# OO style\nuse Digest::HMAC;\n$hmac = Digest::HMAC->new($key, \"Digest::MyHash\");\n$hmac->add($data);\n$hmac->addfile(*FILE);\n$digest = $hmac->digest;\n$digest = $hmac->hexdigest;\n$digest = $hmac->b64digest;",
    "sections": {
        "NAME": {
            "content": "Digest::HMAC - Keyed-Hashing for Message Authentication\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "# Functional style\nuse Digest::HMAC qw(hmac hmachex);\n$digest = hmac($data, $key, \\&myhash);\nprint hmachex($data, $key, \\&myhash);\n\n# OO style\nuse Digest::HMAC;\n$hmac = Digest::HMAC->new($key, \"Digest::MyHash\");\n\n$hmac->add($data);\n$hmac->addfile(*FILE);\n\n$digest = $hmac->digest;\n$digest = $hmac->hexdigest;\n$digest = $hmac->b64digest;\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "HMAC is used for message integrity checks between two parties that share a secret key, and works\nin combination with some other Digest algorithm, usually MD5 or SHA-1. The HMAC mechanism is\ndescribed in RFC 2104.\n\nHMAC follow the common \"Digest::\" interface, but the constructor takes the secret key and the\nname of some other simple \"Digest::\" as argument.\n\nThe hmac() and hmachex() functions and the Digest::HMAC->new() constructor takes an optional\n$blocksize argument as well. The HMAC algorithm assumes the digester to hash by iterating a\nbasic compression function on blocks of data and the $blocksize should match the byte-length of\nsuch blocks.\n\nThe default $blocksize is 64 which is suitable for the MD5 and SHA-1 digest functions. For\nstronger algorithms the blocksize probably needs to be increased.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "Digest::HMACMD5, Digest::HMACSHA1\n\nRFC 2104\n",
            "subsections": []
        },
        "MAINTAINER": {
            "content": "Andrew Rodland <arodland@cpan.org>\n",
            "subsections": []
        },
        "ORIGINAL AUTHORS": {
            "content": "Graham Barr <gbarr@ti.com>, Gisle Aas <gisle@aas.no>\n",
            "subsections": []
        }
    },
    "summary": "Digest::HMAC - Keyed-Hashing for Message Authentication",
    "flags": [],
    "examples": [],
    "see_also": []
}