Crypt::Mode::CFB(3)
π Crypt::Mode::CFB(3) β bestie edition π
okay so this is a User Contributed Perl Documentation page for Crypt::Mode::CFB, and honestly? it's a whole vibe. stick with me, we're gonna get through it together π«Ά
β¨ NAME β¨
Crypt::Mode::CFB β the block cipher mode CFB, which stands for Cipher feedback. yes bestie, feedback like a microphone, but for bytes π€
πΈ SYNOPSIS πΈ
here's the whole flex, look at her go:
use Crypt::Mode::CFB;
my $m = Crypt::Mode::CFB->new('AES');
my $key = '1234567890123456';
my $iv = '1234567890123456';
my $plaintext = 'example plaintext';
my $chunk1 = 'example ';
my $chunk2 = 'plaintext';
# encrypt or decrypt in one call
my $single_ciphertext = $m->encrypt($plaintext, $key, $iv);
my $single_plaintext = $m->decrypt($single_ciphertext, $key, $iv);
# encrypt more chunks
$m->start_encrypt($key, $iv);
my $chunked_ciphertext = '';
$chunked_ciphertext .= $m->add($chunk1);
$chunked_ciphertext .= $m->add($chunk2);
# decrypt more chunks
$m->start_decrypt($key, $iv);
my $chunked_plaintext = '';
$chunked_plaintext .= $m->add($chunked_ciphertext);
like, one-and-done or chunk-by-chunk? she does both. main character energy fr π
π¦ DESCRIPTION π¦
this module implements the CFB cipher mode. it's giving "streaming, no padding, zero drama."
β οΈ important bestie note straight from the source: it works only with ciphers from CryptX, i.e. Crypt::Cipher::NNNN. don't come at her with anything else, she will not know her π
π METHODS π
unless it says otherwise, just assume $m is a mode object that already exists, made via new, like this:
my $m = Crypt::Mode::CFB->new('AES');
π new
my $m = Crypt::Mode::CFB->new($name);
#or
my $m = Crypt::Mode::CFB->new($name, $cipher_rounds);
# $name ............ [string] one of 'AES', 'Anubis', 'Blowfish', 'CAST5', 'Camellia', 'DES', 'DES_EDE',
# 'KASUMI', 'Khazad', 'MULTI2', 'Noekeon', 'RC2', 'RC5', 'RC6',
# 'SAFERP', 'SAFER_K128', 'SAFER_K64', 'SAFER_SK128', 'SAFER_SK64',
# 'SEED', 'Skipjack', 'Twofish', 'XTEA', 'IDEA', 'Serpent'
# or any <NAME> for which there is a Crypt::Cipher::<NAME> module
# $cipher_rounds ... [integer] optional, number of rounds for given cipher
$nameβ a string, one of the cipher names listed above, or literally any<NAME>that has aCrypt::Cipher::<NAME>module out there. the roster is stacked, ngl π$cipher_roundsβ an integer, optional, the number of rounds for that cipher. only if you're feeling fancy β¨
π₯ encrypt
encrypts the plaintext in one single call, no warm-up. hands you back the ciphertext as a binary string π
heads up on the conversion lore: the plaintext scalar gets turned into bytes using Perl's usual scalar stringification. defined scalars are all good β numbers, string-overloaded objects, all of it. undef gets treated as an empty string and might emit Perl's usual "uninitialized value" warning. π
my $ciphertext = $m->encrypt($plaintext, $key, $iv);
β decrypt
same deal but backwards β decrypts the ciphertext in one single call and returns the plaintext as a binary string.
again: the ciphertext scalar is converted to bytes with Perl's usual scalar stringification, defined scalars (numbers, string-overloaded objects) are accepted, and undef is treated as an empty string and may emit Perl's usual "uninitialized value" warning. no cap π§
my $plaintext = $m->decrypt($ciphertext, $key, $iv);
π« start_encrypt
initializes encryption mode. returns the object itself, so she's chainable, she's generous, she's that girl π
$m->start_encrypt($key, $iv);
π start_decrypt
initializes decryption mode. also returns the object itself. symmetric queen πΈ
$m->start_decrypt($key, $iv);
π add
feeds data into the encryption or decryption stream. returns a binary string, always.
each argument gets converted to bytes using Perl's usual scalar stringification β defined scalars incl. numbers and string-overloaded objects are welcome, undef is treated as an empty string and may emit Perl's usual "uninitialized value" warning. same rules, every time, periodt π
# in encrypt mode
my $ciphertext = $m->add($plaintext);
# in decrypt mode
my $plaintext = $m->add($ciphertext);
π finish
okay so CFB is a streaming mode and does not use padding, which means finish returns an empty string. that's not a bug bestie, that's the whole point π
she exists purely for API consistency with Crypt::Mode::CBC and Crypt::Mode::ECB, and you may safely call her or justβ¦ not. both are iconic π«Ά
$m->start_encrypt($key, $iv);
my $ciphertext = '';
$ciphertext .= $m->add($chunk1);
$ciphertext .= $m->add($chunk2);
$ciphertext .= $m->finish; # returns ''
π SEE ALSO π
CryptX,Crypt::CipherCrypt::Cipher::AES,Crypt::Cipher::Blowfish,...- <https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation#Cipher_feedback_.28CFB.29>
and that's the page, bestie!! π¦ run it back any time π
perl v5.42.0 β¨ 2026-05-11 β¨ Crypt::Mode::CFB(3) β that's the version and the date down at the bottom, mwah π go encrypt something gorgeous π
π¦ 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