Links
Archives
Random notes from yet another Finnish nerd. This blog reflects mostly my life with computers and stuff, rather than my real life.
May 29, 2004
Did a bit of Perl hacking today. Encrypting/decrypting a file with Blowfish cipher goes like this:
use Crypt::CBC;
use Crypt::Blowfish;
open(IN, "secret.txt") or die "Unable to open for reading, $!\n";
open(OUT, ">message.txt") or die "Unable to open for writing, $!\n";
binmode IN; # for win32
binmode OUT;
my $cipher = Crypt::CBC->new($key, 'Blowfish');
$cipher->start('decrypting');
my $buff;
while (read(IN, $buff, 1024)) {
my $block = $cipher->crypt($buff);
print OUT $block;
}
close IN;
close OUT;
$cipher->finish();
Comments:
Post a Comment