use warnings; use strict; @ARGV or die "Usage: cipher keyfile < source > dest\n"; open K,shift or die "Can't open keyfile: $!\n"; undef $/; my $k = ; close K; # slurp length $k or die "error reading key file\n"; while (read STDIN, my $t, length $k) { my @k = unpack "C*", $k; print pack "C*", map { $_^shift @k } unpack "C*", $t; }