#!/opt/perl/bin/perl -w use strict; use Crypt::Twofish2; binmode STDOUT; 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); } } sub padtext { my $text = shift; return $text . substr("\000" x 16, 0, 16 - (length($text) % 16)); } scalar(@ARGV) or die "usage: tfenc key\n"; my $key = padkey($ARGV[0]); my $plaintext = ""; while (read(STDIN, my $tmp, 8192)) { $plaintext .= $tmp; } $plaintext = padtext($plaintext); my $cipher = Crypt::Twofish2->new($key, Crypt::Twofish2::MODE_CBC) or die "$!\n"; my $crypted = $cipher->encrypt($plaintext) or die "$!\n"; print $crypted; .