#!/usr/bin/perl

# decrypt - another utility to solve Scan of the Month No.16
# Usage: decrypt -i infile -o outfile

use Getopt::Std;
getopt('i:o:');


open(INPUT, "<".$opt_i) || die "$0: unable to open $opt_i: $!\n";
open(OUTPUT, ">".$opt_o) || die "$0: unable to open $opt_o: $!\n";

while(sysread(INPUT, $char, 1)) {

	# just invert each single bit
	print OUTPUT chr(255-ord($char));
	$characters += 1;
};

close INPUT;
close OUTPUT;

print "File read: $opt_i\n";
print "Characters read: $characters\n\n";
