#!/usr/bin/perl use strict; my @wheel1 = qw( 8 4 6 6 3 3 8 4 ); my @wheel2 = qw( 1 2 4 6 3 8 8 9 5 1 6 1 7 2 8 1 ); print "KEY:"; chomp(my $key = ); my @wheel3 = map(ord, split //, $key); my $file = @ARGV[0]; $/ = undef; print "OPENING $file\n"; open(IN, "$file") || die "painful death! (because there is no $file)"; my ($out); my $plaintext = ; close(IN); open(OUT, ">$file"); my @nums = map(ord, split //, $plaintext); foreach (@nums) { print "*"; my $x = @wheel1[0] + @wheel2[0] + @wheel3[0]; if (@ARGV[1] eq "-d") { $out = $_ + $x; } else { $out = $_ - $x; } $out = chr $out; print OUT $out; push @wheel1, shift @wheel1; push @wheel2, shift @wheel2; print "\b"; }