Crypt::...::ChaCha(3)
π Crypt::Stream::ChaCha β User Contributed Perl Documentation
okay bestie, welcome to the Crypt::...::ChaCha(3) page from User Contributed Perl Documentation β¨ this is the manual for Crypt::Stream::ChaCha, and we're gonna go through it together, no cap. π«Ά
πΈ NAME πΈ
Crypt::Stream::ChaCha β Stream cipher ChaCha π¦
π SYNOPSIS π
like, here's the whole vibe in code, bestie:
use Crypt::Stream::ChaCha;
# encrypt
my $key = "12345678901234567890123456789012"; # 32 bytes
my $nonce = "123456789012"; # 12 bytes
my $enc_stream = Crypt::Stream::ChaCha->new($key, $nonce);
my $ct = $enc_stream->crypt("plain message");
# decrypt
my $dec_stream = Crypt::Stream::ChaCha->new($key, $nonce);
my $pt = $dec_stream->crypt($ct);
π DESCRIPTION π
This module gives you an interface to the ChaCha stream cipher. That's the whole description, short and iconic. π
π₯ METHODS π₯
Unless noted otherwise, assume $stream is an existing stream object created via new, like this:
my $stream = Crypt::Stream::ChaCha->new($key, $nonce);
β¨ new β¨
Make a new stream object, bestie:
my $stream = Crypt::Stream::ChaCha->new($key, $nonce);
#or
my $stream = Crypt::Stream::ChaCha->new($key, $nonce, $counter, $rounds);
# $key .. [binary string] 32 or 16 bytes
# $nonce .. [binary string] 8 or 12 bytes
# $counter .. [integer] initial counter value (DEFAULT: 0)
# for 12-byte nonces the counter must be <= 0xFFFFFFFF
# $rounds .. [integer] rounds (DEFAULT: 20)
The args are giving:
$keyβ [binary string] 32 or 16 bytes$nonceβ [binary string] 8 or 12 bytes$counterβ [integer] initial counter value (DEFAULT:0); for 12-byte nonces the counter must be<= 0xFFFFFFFF$roundsβ [integer] rounds (DEFAULT:20)
π crypt π
Encrypts or decrypts data. The output has the same length as the input. Returns a binary string (raw bytes). π
The input is converted using Perl's usual scalar stringification. Passing undef is treated as an empty string with the usual warning, and numeric scalars are stringified before processing.
my $ciphertext = $stream->crypt($plaintext);
#or
my $plaintext = $stream->crypt($ciphertext);
π keystream π
Returns $length bytes of raw keystream as a binary string. β
The length is taken using Perl's usual numeric coercion. Values that coerce to an oversized unsigned length are rejected as too large.
my $random_key = $stream->keystream($length);
π¦ clone π¦
Returns a copy of the stream cipher object in its current state. Main character energy, but for objects π
my $stream2 = $stream->clone();
π SEE ALSO π
Crypt::Stream::XChaCha,Crypt::Stream::RC4,Crypt::Stream::Sober128,Crypt::Stream::Salsa20,Crypt::Stream::Sosemanukβ the whole friend group π«Ά<https://www.rfc-editor.org/rfc/rfc7539>β the RFC link, iykyk
That's the whole page, bestie π this was perl v5.42.0, dated 2026-05-11, and it's the Crypt::...::ChaCha(3) manual page. slay β¨
π¦ where this page comes from
- opensuse-leap 16.0: perl-CryptX 0.89.0-bp160.1.1 Β· Artistic-1.0 OR GPL-1.0-or-later
- opensuse-leap 16.0: perl-CryptX 0.89.0-bp160.1.1 Β· Artistic-1.0 OR GPL-1.0-or-later
- opensuse-leap 16.0: perl-CryptX 0.89.0-bp160.1.1 Β· Artistic-1.0 OR GPL-1.0-or-later
- opensuse-leap 16.0: perl-CryptX 0.89.0-bp160.1.1 Β· Artistic-1.0 OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms