Crypt::...Salsa20(3)

πŸ’– NAME πŸ’–

okay bestie, this page is Crypt::...Salsa20(3) from User Contributed Perl Documentation, and the icon of the whole thing is Crypt::Stream::Salsa20 β€” Stream cipher Salsa20, periodt. πŸ‘‘

✨ SYNOPSIS ✨

use Crypt::Stream::Salsa20;

# encrypt
my $key = "1234567890123456";
my $nonce  = "12345678";
my $enc_stream = Crypt::Stream::Salsa20->new($key, $nonce);
my $ct = $enc_stream->crypt("plain message");

# decrypt
my $dec_stream = Crypt::Stream::Salsa20->new($key, $nonce);
my $pt = $dec_stream->crypt($ct);

πŸ¦‹ DESCRIPTION πŸ¦‹

lowkey the whole point: this module provides an interface to the Salsa20 stream cipher. that's the vibe, no cap. πŸ’…

πŸŽ€ METHODS πŸŽ€

unless noted otherwise, assume $stream is an existing stream object created via new, for example:

my $stream = Crypt::Stream::Salsa20->new($key, $nonce);

🌸 new 🌸

new is your main character constructor β€” it makes the stream object. you can call it with just key and nonce, or with counter and rounds too:

my $stream = Crypt::Stream::Salsa20->new($key, $nonce);
#or
my $stream = Crypt::Stream::Salsa20->new($key, $nonce, $counter, $rounds);

# $key     .. [binary string] 32 or 16 bytes
# $nonce   .. [binary string] 8 bytes
# $counter .. [integer] initial counter value (DEFAULT: 0)
# $rounds  .. [integer] rounds (DEFAULT: 20)

also, so it's crystal clear:

  • $key β€” [binary string] 32 or 16 bytes πŸ’–
  • $nonce β€” [binary string] 8 bytes ✨
  • $counter β€” [integer] initial counter value (DEFAULT: 0) πŸŽ€
  • $rounds β€” [integer] rounds (DEFAULT: 20) πŸ¦‹

πŸ”₯ crypt πŸ”₯

crypt encrypts or decrypts data. the output has the same length as the input, and it returns a binary string (raw bytes). literally matching energy. 😭

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 β€” so no cursed giant-length shenanigans, bestie πŸ’€

my $random_key = $stream->keystream($length);

🧚 clone 🧚

returns a copy of the stream cipher object in its current state. it's giving save-point energy, honestly. ✨

my $stream2 = $stream->clone();

🌈 SEE ALSO 🌈


that's the page, bestie πŸ’… this was Crypt::...Salsa20(3) from User Contributed Perl Documentation, served with perl v5.42.0 and dated 2026-05-11 β€” bye and stay encrypted πŸŽ€

πŸ“¦ where this page comes from