Help language development. Donate to The Perl Foundation

ENIGMA::Machine cpan:UZLUISF last updated on 2018-11-03

use v6;
use ENIGMA::Machine;

my $text = './keysheet-text.txt'.IO.slurp;

# Build machine from key file (day 31) 
my $machine = Machine.from-key-file($text, 31);

# Take a look at 'encoded-message.txt' for the initial start 
# position and message indicator

# set machine initial star position

# decrypt the message key
my $msg-key = $machine.process-text('BDH');

# set machine to decoded message key

# decode sent message
my $plaintext = $machine.process-text('EBBVDRWEZRVHAFJL', 'X');

say "And the message was: $plaintext\n";

say "By the way, ",
    " is a great song by ",
    $plaintext.split('X')[2], '.';