{
    "mode": "perldoc",
    "parameter": "Crypt::Stream::ChaCha",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/Crypt%3A%3AStream%3A%3AChaCha/json",
    "generated": "2026-10-04T15:31:50Z",
    "synopsis": "use Crypt::Stream::ChaCha;\n# encrypt\n$key = \"1234567890123456\";\n$iv  = \"123456789012\";\n$stream = Crypt::Stream::ChaCha->new($key, $iv);\n$ct = $stream->crypt(\"plain message\");\n# decrypt\n$key = \"1234567890123456\";\n$iv  = \"123456789012\";\n$stream = Crypt::Stream::ChaCha->new($key, $iv);\n$pt = $stream->crypt($ct);",
    "sections": {
        "NAME": {
            "content": "Crypt::Stream::ChaCha - Stream cipher ChaCha\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "use Crypt::Stream::ChaCha;\n\n# encrypt\n$key = \"1234567890123456\";\n$iv  = \"123456789012\";\n$stream = Crypt::Stream::ChaCha->new($key, $iv);\n$ct = $stream->crypt(\"plain message\");\n\n# decrypt\n$key = \"1234567890123456\";\n$iv  = \"123456789012\";\n$stream = Crypt::Stream::ChaCha->new($key, $iv);\n$pt = $stream->crypt($ct);\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "Provides an interface to the ChaCha stream cipher.\n",
            "subsections": []
        },
        "METHODS": {
            "content": "new\n$stream = Crypt::Stream::ChaCha->new($key, $iv);\n#or\n$stream = Crypt::Stream::ChaCha->new($key, $iv, $counter, $rounds);\n\n# $key     .. 32 or 16 bytes\n# $iv      .. 8 or 12 bytes\n# $counter .. initial counter value (DEFAULT: 0)\n# $rounds  .. rounds (DEFAULT: 20)\n\ncrypt\n$ciphertext = $stream->crypt($plaintext);\n#or\n$plaintext = $stream->crypt($ciphertext);\n\nkeystream\n$randomkey = $stream->keystream($length);\n\nclone\n$stream->clone();\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "*   Crypt::Stream::RC4, Crypt::Stream::Sober128, Crypt::Stream::Salsa20,\nCrypt::Stream::Sosemanuk\n\n*   <https://tools.ietf.org/html/rfc7539>\n",
            "subsections": []
        }
    },
    "summary": "Crypt::Stream::ChaCha - Stream cipher ChaCha",
    "flags": [],
    "examples": [],
    "see_also": []
}