Crypt::...semanuk(3)

πŸ’– NAME πŸ’–

Okay bestie, welcome to the Crypt::Stream::Sosemanuk(3) page from User Contributed Perl Documentation β€” and it's all about Crypt::Stream::Sosemanuk, aka the Sosemanuk stream cipher. Stream cipher Sosemanuk, if we're being proper about it. πŸ’…βœ¨


🌸 SYNOPSIS 🌸

Here's the whole vibe: encrypt with one stream object, decrypt with another, same $key and $iv energy. No cap, the code is right here:

use Crypt::Stream::Sosemanuk;

# encrypt
my $key = "1234567890123456";
my $iv  = "123456789012";
my $enc_stream = Crypt::Stream::Sosemanuk->new($key, $iv);
my $ct = $enc_stream->crypt("plain message");

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

πŸ¦‹ DESCRIPTION πŸ¦‹

It provides an interface to the Sosemanuk stream cipher. That's the whole description, and honestly? Iconic. πŸ’–


✨ METHODS ✨

Unless noted otherwise, assume $stream is an existing stream object you already made with new, like this little cutie:

my $stream = Crypt::Stream::Sosemanuk->new($key, $iv);

πŸŽ€ new πŸŽ€

Make a fresh stream object, bestie. Signature:

my $stream = Crypt::Stream::Sosemanuk->new($key, $iv);
# $key .. [binary string] keylen must be multiple of 4 bytes
# $iv  .. [binary string] ivlen must be multiple of 4 bytes (OPTIONAL - simply omit to skip IV setup)

So $key is a binary string, and keylen must be a multiple of 4 bytes. $iv is also a binary string, and ivlen must be a multiple of 4 bytes β€” but it's OPTIONAL, so simply omit it to skip IV setup. Slay. 🫢

πŸ” crypt πŸ”

Encrypts or decrypts data, depending on what you feed it. The output has the same length as the input, and you get back a binary string (raw bytes).

Input handling? It gets 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. So yeah, Perl doing Perl things, but make it cipher. 😭

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 β€” no giant accidental length gremlins, bestie.

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

🧬 clone 🧬

Returns a copy of the stream cipher object in its current state. Snapshot realness. πŸ“Έ

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

πŸ‘‘ SEE ALSO πŸ‘‘

Go peek at these other stream ciphers and the Sosemanuk lore:


Sign-off, bestie: this page is from source/version perl v5.42.0, dated 2026-05-11, and it's the Crypt::...semanuk(3) manual page. Now go slay those streams fr fr πŸ’–βœ¨πŸ«Ά
πŸ“¦ where this page comes from