#!/opt/perl/bin/perl -w use strict; use Crypt::Twofish2; binmode STDIN; sub padkey { my $key = shift; if (length($key) < 32) { return $key . substr("\000" x 32, 0, 32 - length($key)); } else { return substr($key, 0, 32); } } scalar(@ARGV) or die "usage: tfdec key\n"; my $key = padkey($ARGV[0]); my $crypted = ""; while (read(STDIN, my $tmp, 8192)) { $crypted .= $tmp; } my $cipher = Crypt::Twofish2->new($key, Crypt::Twofish2::MODE_CBC) or die "$!\n"; my $plaintext = $cipher->decrypt($crypted) or die "$!\n"; $plaintext =~ s/\000+$//; print $plaintext; .