{
    "content": [
        {
            "type": "text",
            "text": "# Crypt::Cipher (perldoc)\n\n## NAME\n\nCrypt::Cipher - Generic interface to cipher functions\n\n## SYNOPSIS\n\n#### example 1 (encrypting single block)\nuse Crypt::Cipher;\nmy $key = '...'; # length has to be valid key size for this cipher\nmy $c = Crypt::Cipher->new('AES', $key);\nmy $blocksize  = $c->blocksize;\nmy $ciphertext = $c->encrypt('plain text block'); #encrypt 1 block\nmy $plaintext  = $c->decrypt($ciphertext);         #decrypt 1 block\n### example 2 (using CBC mode)\nuse Crypt::Mode::CBC;\nmy $key = '...'; # length has to be valid key size for this cipher\nmy $iv = '...';  # 16 bytes\nmy $cbc = Crypt::Mode::CBC->new('AES');\nmy $ciphertext = $cbc->encrypt(\"secret data\", $key, $iv);\n#### example 3 (compatibility with Crypt::CBC)\nuse Crypt::CBC;\nuse Crypt::Cipher;\nmy $key = '...'; # length has to be valid key size for this cipher\nmy $iv = '...';  # 16 bytes\nmy $cipher = Crypt::Cipher('AES', $key);\nmy $cbc = Crypt::CBC->new( -cipher=>$cipher, -iv=>$iv );\nmy $ciphertext = $cbc->encrypt(\"secret data\");\n\n## DESCRIPTION\n\nProvides an interface to various symmetric cipher algorithms.\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **DESCRIPTION**\n- **METHODS**\n- **SEE ALSO**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "Crypt::Cipher",
        "section": "",
        "mode": "perldoc",
        "summary": "Crypt::Cipher - Generic interface to cipher functions",
        "synopsis": "#### example 1 (encrypting single block)\nuse Crypt::Cipher;\nmy $key = '...'; # length has to be valid key size for this cipher\nmy $c = Crypt::Cipher->new('AES', $key);\nmy $blocksize  = $c->blocksize;\nmy $ciphertext = $c->encrypt('plain text block'); #encrypt 1 block\nmy $plaintext  = $c->decrypt($ciphertext);         #decrypt 1 block\n### example 2 (using CBC mode)\nuse Crypt::Mode::CBC;\nmy $key = '...'; # length has to be valid key size for this cipher\nmy $iv = '...';  # 16 bytes\nmy $cbc = Crypt::Mode::CBC->new('AES');\nmy $ciphertext = $cbc->encrypt(\"secret data\", $key, $iv);\n#### example 3 (compatibility with Crypt::CBC)\nuse Crypt::CBC;\nuse Crypt::Cipher;\nmy $key = '...'; # length has to be valid key size for this cipher\nmy $iv = '...';  # 16 bytes\nmy $cipher = Crypt::Cipher('AES', $key);\nmy $cbc = Crypt::CBC->new( -cipher=>$cipher, -iv=>$iv );\nmy $ciphertext = $cbc->encrypt(\"secret data\");",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 27,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 6,
                "subsections": []
            },
            {
                "name": "METHODS",
                "lines": 68,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 4,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "Crypt::Cipher - Generic interface to cipher functions\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "#### example 1 (encrypting single block)\nuse Crypt::Cipher;\n\nmy $key = '...'; # length has to be valid key size for this cipher\nmy $c = Crypt::Cipher->new('AES', $key);\nmy $blocksize  = $c->blocksize;\nmy $ciphertext = $c->encrypt('plain text block'); #encrypt 1 block\nmy $plaintext  = $c->decrypt($ciphertext);         #decrypt 1 block\n\n### example 2 (using CBC mode)\nuse Crypt::Mode::CBC;\n\nmy $key = '...'; # length has to be valid key size for this cipher\nmy $iv = '...';  # 16 bytes\nmy $cbc = Crypt::Mode::CBC->new('AES');\nmy $ciphertext = $cbc->encrypt(\"secret data\", $key, $iv);\n\n#### example 3 (compatibility with Crypt::CBC)\nuse Crypt::CBC;\nuse Crypt::Cipher;\n\nmy $key = '...'; # length has to be valid key size for this cipher\nmy $iv = '...';  # 16 bytes\nmy $cipher = Crypt::Cipher('AES', $key);\nmy $cbc = Crypt::CBC->new( -cipher=>$cipher, -iv=>$iv );\nmy $ciphertext = $cbc->encrypt(\"secret data\");\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "Provides an interface to various symmetric cipher algorithms.\n\nBEWARE: This module implements just elementary \"one-block-(en|de)cryption\" operation - if you\nwant to encrypt/decrypt generic data you have to use some of the cipher block modes - check for\nexample Crypt::Mode::CBC, Crypt::Mode::CTR or Crypt::CBC (which will be slower).\n",
                "subsections": []
            },
            "METHODS": {
                "content": "new\nConstructor, returns a reference to the cipher object.\n\n## basic scenario\n$d = Crypt::Cipher->new($name, $key);\n# $name = one of 'AES', 'Anubis', 'Blowfish', 'CAST5', 'Camellia', 'DES', 'DESEDE',\n#                'KASUMI', 'Khazad', 'MULTI2', 'Noekeon', 'RC2', 'RC5', 'RC6',\n#                'SAFERP', 'SAFERK128', 'SAFERK64', 'SAFERSK128', 'SAFERSK64',\n#                'SEED', 'Skipjack', 'Twofish', 'XTEA', 'IDEA', 'Serpent'\n#                simply any <NAME> for which there exists Crypt::Cipher::<NAME>\n# $key = binary key (keysize should comply with selected cipher requirements)\n\n## some of the ciphers (e.g. MULTI2, RC5, SAFER) allow one to set number of rounds\n$d = Crypt::Cipher->new('MULTI2', $key, $rounds);\n# $rounds = positive integer (should comply with selected cipher requirements)\n\nencrypt\nEncrypts $plaintext and returns the $ciphertext where $plaintext and $ciphertext should be of\nblocksize bytes.\n\n$ciphertext = $d->encrypt($plaintext);\n\ndecrypt\nDecrypts $ciphertext and returns the $plaintext where $plaintext and $ciphertext should be of\nblocksize bytes.\n\n$plaintext = $d->decrypt($ciphertext);\n\nkeysize\nJust an alias for maxkeysize (needed for Crypt::CBC compatibility).\n\nmaxkeysize\nReturns the maximal allowed key size (in bytes) for given cipher.\n\n$d->maxkeysize;\n#or\nCrypt::Cipher->maxkeysize('AES');\n#or\nCrypt::Cipher::maxkeysize('AES');\n\nminkeysize\nReturns the minimal allowed key size (in bytes) for given cipher.\n\n$d->minkeysize;\n#or\nCrypt::Cipher->minkeysize('AES');\n#or\nCrypt::Cipher::minkeysize('AES');\n\nblocksize\nReturns block size (in bytes) for given cipher.\n\n$d->blocksize;\n#or\nCrypt::Cipher->blocksize('AES');\n#or\nCrypt::Cipher::blocksize('AES');\n\ndefaultrounds\nReturns default number of rounds for given cipher. NOTE: only some ciphers (e.g. MULTI2, RC5,\nSAFER) allow one to set number of rounds via new().\n\n$d->defaultrounds;\n#or\nCrypt::Cipher->defaultrounds('AES');\n#or\nCrypt::Cipher::defaultrounds('AES');\n",
                "subsections": []
            },
            "SEE ALSO": {
                "content": "*   CryptX\n\n*   Check subclasses like Crypt::Cipher::AES, Crypt::Cipher::Blowfish, ...\n",
                "subsections": []
            }
        }
    }
}