{
    "content": [
        {
            "type": "text",
            "text": "# Crypt::Mode::CBC (perldoc)\n\n## NAME\n\nCrypt::Mode::CBC - Block cipher mode CBC [Cipher-block chaining]\n\n## SYNOPSIS\n\nuse Crypt::Mode::CBC;\nmy $m = Crypt::Mode::CBC->new('AES');\n#(en|de)crypt at once\nmy $ciphertext = $m->encrypt($plaintext, $key, $iv);\nmy $plaintext = $m->decrypt($ciphertext, $key, $iv);\n#encrypt more chunks\n$m->startencrypt($key, $iv);\nmy $ciphertext = $m->add('some data');\n$ciphertext .= $m->add('more data');\n$ciphertext .= $m->finish;\n#decrypt more chunks\n$m->startdecrypt($key, $iv);\nmy $plaintext = $m->add($someciphertext);\n$plaintext .= $m->add($moreciphertext);\n$plaintext .= $m->finish;\n\n## DESCRIPTION\n\nThis module implements CBC cipher mode. NOTE: it works only with ciphers from CryptX\n(Crypt::Cipher::NNNN).\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::Mode::CBC",
        "section": "",
        "mode": "perldoc",
        "summary": "Crypt::Mode::CBC - Block cipher mode CBC [Cipher-block chaining]",
        "synopsis": "use Crypt::Mode::CBC;\nmy $m = Crypt::Mode::CBC->new('AES');\n#(en|de)crypt at once\nmy $ciphertext = $m->encrypt($plaintext, $key, $iv);\nmy $plaintext = $m->decrypt($ciphertext, $key, $iv);\n#encrypt more chunks\n$m->startencrypt($key, $iv);\nmy $ciphertext = $m->add('some data');\n$ciphertext .= $m->add('more data');\n$ciphertext .= $m->finish;\n#decrypt more chunks\n$m->startdecrypt($key, $iv);\nmy $plaintext = $m->add($someciphertext);\n$plaintext .= $m->add($moreciphertext);\n$plaintext .= $m->finish;",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 19,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 3,
                "subsections": []
            },
            {
                "name": "METHODS",
                "lines": 54,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 7,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "Crypt::Mode::CBC - Block cipher mode CBC [Cipher-block chaining]\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "use Crypt::Mode::CBC;\nmy $m = Crypt::Mode::CBC->new('AES');\n\n#(en|de)crypt at once\nmy $ciphertext = $m->encrypt($plaintext, $key, $iv);\nmy $plaintext = $m->decrypt($ciphertext, $key, $iv);\n\n#encrypt more chunks\n$m->startencrypt($key, $iv);\nmy $ciphertext = $m->add('some data');\n$ciphertext .= $m->add('more data');\n$ciphertext .= $m->finish;\n\n#decrypt more chunks\n$m->startdecrypt($key, $iv);\nmy $plaintext = $m->add($someciphertext);\n$plaintext .= $m->add($moreciphertext);\n$plaintext .= $m->finish;\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "This module implements CBC cipher mode. NOTE: it works only with ciphers from CryptX\n(Crypt::Cipher::NNNN).\n",
                "subsections": []
            },
            "METHODS": {
                "content": "new\nmy $m = Crypt::Mode::CBC->new($name);\n#or\nmy $m = Crypt::Mode::CBC->new($name, $padding);\n#or\nmy $m = Crypt::Mode::CBC->new($name, $padding, $cipherrounds);\n\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# $padding .... 0 no padding (plaintext size has to be multiple of block length)\n#               1 PKCS5 padding, Crypt::CBC's \"standard\" - DEFAULT\n#               2 Crypt::CBC's \"oneandzeroes\"\n#               3 ANSI X.923 padding\n#               4 zero padding\n#               5 zero padding (+a block of zeros if the output length is divisible by the blocksize)\n# $cipherrounds ... optional num of rounds for given cipher\n\nencrypt\nmy $ciphertext = $m->encrypt($plaintext, $key, $iv);\n\ndecrypt\nmy $plaintext = $m->decrypt($ciphertext, $key, $iv);\n\nstartencrypt\n$m->startencrypt($key, $iv);\n\nstartdecrypt\n$m->startdecrypt($key, $iv);\n\nadd\n# in encrypt mode\nmy $plaintext = $m->add($ciphertext);\n\n# in decrypt mode\nmy $ciphertext = $m->add($plaintext);\n\nfinish\n#encrypt more chunks\n$m->startencrypt($key, $iv);\nmy $ciphertext = '';\n$ciphertext .= $m->add('some data');\n$ciphertext .= $m->add('more data');\n$ciphertext .= $m->finish;\n\n#decrypt more chunks\n$m->startdecrypt($key, $iv);\nmy $plaintext = '';\n$plaintext .= $m->add($someciphertext);\n$plaintext .= $m->add($moreciphertext);\n$plaintext .= $m->finish;\n",
                "subsections": []
            },
            "SEE ALSO": {
                "content": "*   CryptX, Crypt::Cipher\n\n*   Crypt::Cipher::AES, Crypt::Cipher::Blowfish, ...\n\n*   <https://en.wikipedia.org/wiki/Blockciphermodeofoperation#Cipher-blockchaining.28CBC.2\n9>\n",
                "subsections": []
            }
        }
    }
}