{
    "mode": "perldoc",
    "parameter": "Crypt::AuthEnc::EAX",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/Crypt%3A%3AAuthEnc%3A%3AEAX/json",
    "generated": "2026-06-12T21:28:39Z",
    "synopsis": "### OO interface\nuse Crypt::AuthEnc::EAX;\n# encrypt and authenticate\nmy $ae = Crypt::AuthEnc::EAX->new(\"AES\", $key, $iv);\n$ae->adataadd('additionalauthenticateddata1');\n$ae->adataadd('additionalauthenticateddata2');\nmy $ct = $ae->encryptadd('data1');\n$ct .= $ae->encryptadd('data2');\n$ct .= $ae->encryptadd('data3');\nmy $tag = $ae->encryptdone();\n# decrypt and verify\nmy $ae = Crypt::AuthEnc::EAX->new(\"AES\", $key, $iv);\n$ae->adataadd('additionalauthenticateddata1');\n$ae->adataadd('additionalauthenticateddata2');\nmy $pt = $ae->decryptadd('ciphertext1');\n$pt .= $ae->decryptadd('ciphertext2');\n$pt .= $ae->decryptadd('ciphertext3');\nmy $tag = $ae->decryptdone();\ndie \"decrypt failed\" unless $tag eq $expectedtag;\n#or\nmy $result = $ae->decryptdone($expectedtag); # 0 or 1\n### functional interface\nuse Crypt::AuthEnc::EAX qw(eaxencryptauthenticate eaxdecryptverify);\nmy ($ciphertext, $tag) = eaxencryptauthenticate('AES', $key, $iv, $adata, $plaintext);\nmy $plaintext = eaxdecryptverify('AES', $key, $iv, $adata, $ciphertext, $tag);",
    "sections": {
        "NAME": {
            "content": "Crypt::AuthEnc::EAX - Authenticated encryption in EAX mode\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "### OO interface\nuse Crypt::AuthEnc::EAX;\n\n# encrypt and authenticate\nmy $ae = Crypt::AuthEnc::EAX->new(\"AES\", $key, $iv);\n$ae->adataadd('additionalauthenticateddata1');\n$ae->adataadd('additionalauthenticateddata2');\nmy $ct = $ae->encryptadd('data1');\n$ct .= $ae->encryptadd('data2');\n$ct .= $ae->encryptadd('data3');\nmy $tag = $ae->encryptdone();\n\n# decrypt and verify\nmy $ae = Crypt::AuthEnc::EAX->new(\"AES\", $key, $iv);\n$ae->adataadd('additionalauthenticateddata1');\n$ae->adataadd('additionalauthenticateddata2');\nmy $pt = $ae->decryptadd('ciphertext1');\n$pt .= $ae->decryptadd('ciphertext2');\n$pt .= $ae->decryptadd('ciphertext3');\nmy $tag = $ae->decryptdone();\ndie \"decrypt failed\" unless $tag eq $expectedtag;\n\n#or\nmy $result = $ae->decryptdone($expectedtag); # 0 or 1\n\n### functional interface\nuse Crypt::AuthEnc::EAX qw(eaxencryptauthenticate eaxdecryptverify);\n\nmy ($ciphertext, $tag) = eaxencryptauthenticate('AES', $key, $iv, $adata, $plaintext);\nmy $plaintext = eaxdecryptverify('AES', $key, $iv, $adata, $ciphertext, $tag);\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "EAX is a mode that requires a cipher, CTR and OMAC support and provides encryption and\nauthentication. It is initialized with a random IV that can be shared publicly, additional\nauthenticated data which can be fixed and public, and a random secret symmetric key.\n",
            "subsections": []
        },
        "EXPORT": {
            "content": "Nothing is exported by default.\n\nYou can export selected functions:\n\nuse Crypt::AuthEnc::EAX qw(eaxencryptauthenticate eaxdecryptverify);\n",
            "subsections": []
        },
        "FUNCTIONS": {
            "content": "eaxencryptauthenticate\nmy ($ciphertext, $tag) = eaxencryptauthenticate($cipher, $key, $iv, $adata, $plaintext);\n\n# $cipher .. 'AES' or name of any other cipher with 16-byte block len\n# $key ..... AES key of proper length (128/192/256bits)\n# $iv ...... unique initialization vector (no need to keep it secret)\n# $adata ... additional authenticated data\n\neaxdecryptverify\nmy $plaintext = eaxdecryptverify($cipher, $key, $iv, $adata, $ciphertext, $tag);\n# on error returns undef\n",
            "subsections": []
        },
        "METHODS": {
            "content": "new\nmy $ae = Crypt::AuthEnc::EAX->new($cipher, $key, $iv);\n#or\nmy $ae = Crypt::AuthEnc::EAX->new($cipher, $key, $iv, $adata);\n\n# $cipher .. 'AES' or name of any other cipher with 16-byte block len\n# $key ..... AES key of proper length (128/192/256bits)\n# $iv ...... unique initialization vector (no need to keep it secret)\n# $adata ... additional authenticated data (optional)\n\nadataadd\n$ae->adataadd($adata);                        # can be called multiple times\n\nencryptadd\n$ciphertext = $ae->encryptadd($data);         # can be called multiple times\n\nencryptdone\n$tag = $ae->encryptdone();                    # returns $tag value\n\ndecryptadd\n$plaintext = $ae->decryptadd($ciphertext);    # can be called multiple times\n\ndecryptdone\nmy $tag = $ae->decryptdone;           # returns $tag value\n#or\nmy $result = $ae->decryptdone($tag);  # returns 1 (success) or 0 (failure)\n\nclone\nmy $aenew = $ae->clone;\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "*   CryptX, Crypt::AuthEnc::CCM, Crypt::AuthEnc::GCM, Crypt::AuthEnc::OCB\n\n*   <https://en.wikipedia.org/wiki/EAXmode>\n",
            "subsections": []
        }
    },
    "summary": "Crypt::AuthEnc::EAX - Authenticated encryption in EAX mode",
    "flags": [],
    "examples": [],
    "see_also": []
}