in reply to Short & Sweet Encryption?

You could use Crypt::Twofish2. The produced encrypted strings are multiple of 16 Bytes of length.

To convert the encrypted text to printable chars, you have to uuencode (or base64 encode) it. Example:

use Crypt::Twofish2; use MIME::Base64; $cipher = new Crypt::Twofish2 "a" x 32, Crypt::Twofish2::MODE_CBC; my $text = "random text!"; print length($text),": $text\n"; # make text a multiple of 128 bit $text .= " " x (16 - length($text) % 16); $crypted = encode_base64($cipher->encrypt($text)); print length($crypted),": $crypted\n"; __END__ 12: random text! 25: ZA5yODJpIrGnOXpzt3hDVQ==
Short enough and (somewhat)secure (well, the above aa.. cipher is silly :-)

--shmem

_($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                              /\_¯/(q    /
----------------------------  \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}

Replies are listed 'Best First'.
Re^2: Short & Sweet Encryption?
by ikegami (Patriarch) on Jul 29, 2006 at 17:49 UTC

    In case someone thinks "It's Twofish, so it must be secure.", the parent's solution doesn't use salting, so you don't get the full security of Twofish. In fact, it's severly weakened. (Also, you might want to use a key other than "a" x 32.) My Blowfish solution has the same limitation.