{
    "mode": "perldoc",
    "parameter": "Crypt::Mac::OMAC",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/Crypt%3A%3AMac%3A%3AOMAC/json",
    "generated": "2026-06-12T15:46:16Z",
    "synopsis": "### Functional interface:\nuse Crypt::Mac::OMAC qw( omac omachex );\n# calculate MAC from string/buffer\n$omacraw  = omac($ciphername, $key, 'data buffer');\n$omachex  = omachex($ciphername, $key, 'data buffer');\n$omacb64  = omacb64($ciphername, $key, 'data buffer');\n$omacb64u = omacb64u($ciphername, $key, 'data buffer');\n### OO interface:\nuse Crypt::Mac::OMAC;\n$d = Crypt::Mac::OMAC->new($ciphername, $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",
    "sections": {
        "NAME": {
            "content": "Crypt::Mac::OMAC - Message authentication code OMAC\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "### Functional interface:\nuse Crypt::Mac::OMAC qw( omac omachex );\n\n# calculate MAC from string/buffer\n$omacraw  = omac($ciphername, $key, 'data buffer');\n$omachex  = omachex($ciphername, $key, 'data buffer');\n$omacb64  = omacb64($ciphername, $key, 'data buffer');\n$omacb64u = omacb64u($ciphername, $key, 'data buffer');\n\n### OO interface:\nuse Crypt::Mac::OMAC;\n\n$d = Crypt::Mac::OMAC->new($ciphername, $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 OMAC message authentication code (MAC) algorithm.\n",
            "subsections": []
        },
        "EXPORT": {
            "content": "Nothing is exported by default.\n\nYou can export selected functions:\n\nuse Crypt::Mac::OMAC qw(omac omachex );\n\nOr all of them at once:\n\nuse Crypt::Mac::OMAC ':all';\n",
            "subsections": []
        },
        "FUNCTIONS": {
            "content": "omac\nLogically joins all arguments into a single string, and returns its OMAC message authentication\ncode encoded as a binary string.\n\n$omacraw = omac($ciphername, $key, 'data buffer');\n#or\n$omacraw = omac($ciphername, $key, 'any data', 'more data', 'even more data');\n\nomachex\nLogically joins all arguments into a single string, and returns its OMAC message authentication\ncode encoded as a hexadecimal string.\n\n$omachex = omachex($ciphername, $key, 'data buffer');\n#or\n$omachex = omachex($ciphername, $key, 'any data', 'more data', 'even more data');\n\nomacb64\nLogically joins all arguments into a single string, and returns its OMAC message authentication\ncode encoded as a Base64 string.\n\n$omacb64 = omacb64($ciphername, $key, 'data buffer');\n#or\n$omacb64 = omacb64($ciphername, $key, 'any data', 'more data', 'even more data');\n\nomacb64u\nLogically joins all arguments into a single string, and returns its OMAC message authentication\ncode encoded as a Base64 URL Safe string (see RFC 4648 section 5).\n\n$omacb64url = omacb64u($ciphername, $key, 'data buffer');\n#or\n$omacb64url = omacb64u($ciphername, $key, 'any data', 'more data', 'even more data');\n",
            "subsections": []
        },
        "METHODS": {
            "content": "new\n$d = Crypt::Mac::OMAC->new($ciphername, $key);\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/OMAC%28cryptography%29>\n",
            "subsections": []
        }
    },
    "summary": "Crypt::Mac::OMAC - Message authentication code OMAC",
    "flags": [],
    "examples": [],
    "see_also": []
}