{
    "content": [
        {
            "type": "text",
            "text": "# Crypt::Mac::HMAC (perldoc)\n\n## NAME\n\nCrypt::Mac::HMAC - Message authentication code HMAC\n\n## SYNOPSIS\n\n### Functional interface:\nuse Crypt::Mac::HMAC qw( hmac hmachex );\n# calculate MAC from string/buffer\n$hmacraw  = hmac('SHA256', $key, 'data buffer');\n$hmachex  = hmachex('SHA256', $key, 'data buffer');\n$hmacb64  = hmacb64('SHA256', $key, 'data buffer');\n$hmacb64u = hmacb64u('SHA256', $key, 'data buffer');\n### OO interface:\nuse Crypt::Mac::HMAC;\n$d = Crypt::Mac::HMAC->new('SHA256', $key);\n$d->add('any data');\n$d->addfile('filename.dat');\n$d->addfile(*FILEHANDLE);\n$resultraw  = $d->mac;     # raw bytes\n$resulthex  = $d->hexmac;  # hexadecimal form\n$resultb64  = $d->b64mac;  # Base64 form\n$resultb64u = $d->b64umac; # Base64 URL Safe form\n\n## DESCRIPTION\n\nProvides an interface to the HMAC message authentication code (MAC) algorithm.\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **DESCRIPTION**\n- **EXPORT**\n- **FUNCTIONS**\n- **METHODS**\n- **SEE ALSO**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "Crypt::Mac::HMAC",
        "section": "",
        "mode": "perldoc",
        "summary": "Crypt::Mac::HMAC - Message authentication code HMAC",
        "synopsis": "### Functional interface:\nuse Crypt::Mac::HMAC qw( hmac hmachex );\n# calculate MAC from string/buffer\n$hmacraw  = hmac('SHA256', $key, 'data buffer');\n$hmachex  = hmachex('SHA256', $key, 'data buffer');\n$hmacb64  = hmacb64('SHA256', $key, 'data buffer');\n$hmacb64u = hmacb64u('SHA256', $key, 'data buffer');\n### OO interface:\nuse Crypt::Mac::HMAC;\n$d = Crypt::Mac::HMAC->new('SHA256', $key);\n$d->add('any data');\n$d->addfile('filename.dat');\n$d->addfile(*FILEHANDLE);\n$resultraw  = $d->mac;     # raw bytes\n$resulthex  = $d->hexmac;  # hexadecimal form\n$resultb64  = $d->b64mac;  # Base64 form\n$resultb64u = $d->b64umac; # Base64 URL Safe form",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 21,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "EXPORT",
                "lines": 10,
                "subsections": []
            },
            {
                "name": "FUNCTIONS",
                "lines": 44,
                "subsections": []
            },
            {
                "name": "METHODS",
                "lines": 34,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 6,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "Crypt::Mac::HMAC - Message authentication code HMAC\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "### Functional interface:\nuse Crypt::Mac::HMAC qw( hmac hmachex );\n\n# calculate MAC from string/buffer\n$hmacraw  = hmac('SHA256', $key, 'data buffer');\n$hmachex  = hmachex('SHA256', $key, 'data buffer');\n$hmacb64  = hmacb64('SHA256', $key, 'data buffer');\n$hmacb64u = hmacb64u('SHA256', $key, 'data buffer');\n\n### OO interface:\nuse Crypt::Mac::HMAC;\n\n$d = Crypt::Mac::HMAC->new('SHA256', $key);\n$d->add('any data');\n$d->addfile('filename.dat');\n$d->addfile(*FILEHANDLE);\n$resultraw  = $d->mac;     # raw bytes\n$resulthex  = $d->hexmac;  # hexadecimal form\n$resultb64  = $d->b64mac;  # Base64 form\n$resultb64u = $d->b64umac; # Base64 URL Safe form\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "Provides an interface to the HMAC message authentication code (MAC) algorithm.\n",
                "subsections": []
            },
            "EXPORT": {
                "content": "Nothing is exported by default.\n\nYou can export selected functions:\n\nuse Crypt::Mac::HMAC qw(hmac hmachex );\n\nOr all of them at once:\n\nuse Crypt::Mac::HMAC ':all';\n",
                "subsections": []
            },
            "FUNCTIONS": {
                "content": "hmac\nLogically joins all arguments into a single string, and returns its HMAC message authentication\ncode encoded as a binary string.\n\n$hmacraw = hmac($hashname, $key, 'data buffer');\n#or\n$hmacraw = hmac($hashname, $key, 'any data', 'more data', 'even more data');\n\n# $hashname ... any <NAME> for which there exists Crypt::Digest::<NAME>\n# $key ......... the key (octets/bytes)\n\nhmachex\nLogically joins all arguments into a single string, and returns its HMAC message authentication\ncode encoded as a hexadecimal string.\n\n$hmachex = hmachex($hashname, $key, 'data buffer');\n#or\n$hmachex = hmachex($hashname, $key, 'any data', 'more data', 'even more data');\n\n# $hashname ... any <NAME> for which there exists Crypt::Digest::<NAME>\n# $key ......... the key (octets/bytes, not hex!)\n\nhmacb64\nLogically joins all arguments into a single string, and returns its HMAC message authentication\ncode encoded as a Base64 string.\n\n$hmacb64 = hmacb64($hashname, $key, 'data buffer');\n#or\n$hmacb64 = hmacb64($hashname, $key, 'any data', 'more data', 'even more data');\n\n# $hashname ... any <NAME> for which there exists Crypt::Digest::<NAME>\n# $key ......... the key (octets/bytes, not Base64!)\n\nhmacb64u\nLogically joins all arguments into a single string, and returns its HMAC message authentication\ncode encoded as a Base64 URL Safe string (see RFC 4648 section 5).\n\n$hmacb64url = hmacb64u($hashname, $key, 'data buffer');\n#or\n$hmacb64url = hmacb64u($hashname, $key, 'any data', 'more data', 'even more data');\n\n# $hashname ... any <NAME> for which there exists Crypt::Digest::<NAME>\n# $key ......... the key (octets/bytes, not Base64url!)\n",
                "subsections": []
            },
            "METHODS": {
                "content": "new\n$d = Crypt::Mac::HMAC->new($hashname, $key);\n\n# $hashname ... any <NAME> for which there exists Crypt::Digest::<NAME>\n# $key ......... the key (octets/bytes)\n\nclone\n$d->clone();\n\nreset\n$d->reset();\n\nadd\n$d->add('any data');\n#or\n$d->add('any data', 'more data', 'even more data');\n\naddfile\n$d->addfile('filename.dat');\n#or\n$d->addfile(*FILEHANDLE);\n\nmac\n$resultraw = $d->mac();\n\nhexmac\n$resulthex = $d->hexmac();\n\nb64mac\n$resultb64 = $d->b64mac();\n\nb64umac\n$resultb64url = $d->b64umac();\n",
                "subsections": []
            },
            "SEE ALSO": {
                "content": "*   CryptX\n\n*   <https://en.wikipedia.org/wiki/Hmac>\n\n*   <https://tools.ietf.org/html/rfc2104>\n",
                "subsections": []
            }
        }
    }
}