#!/usr/bin/perl use strict; use warnings; my @Chars = ('a'..'z', 0..9); my %IndexToADFGVX = (0, 'A', 1, 'D', 2, 'F', 3, 'G', 4, 'V', 5, 'X'); sub gen_keymix {     my @mixed = @Chars;     for(my $i = scalar @mixed; $i > 1;) {         my $r = int(rand($i--));         ($mixed[$i], $mixed[$r]) = ($mixed[$r], $mixed[$i]);     }     return @mixed; } sub gen_keytable {     my (@mixed) = @_;     my %table = ();     for my $row (0 .. 5) {         for my $col (0 .. 5) {             $table{shift @mixed} = $IndexToADFGVX{$row}.$IndexToADFGVX{$col};         }     }     return %table; } sub adfgvx_crypt {     my ($table, $data) = @_;     my $result = join "", map {         $table->{$_},     } split //, $data;     return $result; } my @key = &gen_keymix; my %tab = &gen_keytable(@key); print adfgvx_crypt(\%tab, 'aperlhacker');