| 1 | #!/usr/local/bin/perl -w | ||
| 2 | use Crypt::Enigma; | ||
| 3 | |||
| 4 | if (! $ARGV[0]) { | ||
| 5 | print "Usage: $0 <ROTORS> <RINGS> <INTIALSETTINGS> <INPUT>\n"; | ||
| 6 | exit (); | ||
| 7 | } | ||
| 8 | |||
| 9 | $rotors = $ARGV[0]; | ||
| 10 | $rings = $ARGV[1]; | ||
| 11 | $initial_settings = $ARGV[2]; | ||
| 12 | @input = split (//, $ARGV[3]); | ||
| 13 | |||
| 14 | $enigma = Crypt::Enigma->new (); | ||
| 15 | |||
| 16 | $enigma->setup ($rotors, $rings, $initial_settings); | ||
| 17 | $enigma->stekker ("a", "b"); | ||
| 18 | |||
| 19 | foreach $input (@input) { | ||
| 20 | $output = $enigma->input ($input); | ||
| 21 | $results .= $output; | ||
| 22 | } | ||
| 23 | |||
| 24 | |||
| 25 | print "Input is $ARGV[3]\n"; | ||
| 26 | print "Result is $results\n"; |