#!/usr/bin/perl
### Encrypted ein File mit Blowfish

use warnings;

use lib '/home/ingolf/perl';
use Crypt::Blowfish_PP;

$file = shift;
$key = shift;

$blowfish=new Crypt::Blowfish_PP($key);

open(ORIG, "$file");
open(TEMP, ">blowtemp");

{ local $/; $input = <ORIG>; }
print TEMP pack("u", $input);

close(TEMP);
close(ORIG);

open(TEMP, "blowtemp");
open(OUT, ">$file.enc");

while(read TEMP, $buf, 8){
  $ct=$blowfish->encrypt($buf);
  $unpacked = unpack("H*",$ct);
  print OUT $unpacked;
}

close(TEMP);
close(OUT);
unlink<blowtemp*>;

