summaryrefslogtreecommitdiff
path: root/t/simple-enigma.t
blob: b2bcbddae9cd406dad967bf6be6332843adf3587 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!perl 
use DAKKAR::p 'test';
 
use Enigmatic::Machine;
 
sub real_machine {
    return  Enigmatic::Machine->new({
        reflector => 'B_thin',
        rotors => [ 'I''IV''II''Beta' ],
        plugboard => 'AT BL DF GJ HM NW OP QY RZ VX',
        ring_settings => [ 'V''A''A''A' ],
        rotor_positions => [ 'A''N''J''V' ],
    });
}
 
my $plaintext = 'this is a simple text to be encrypted by an enigma machine'->uc;
note "encrypt simple";
my $ciphertext = real_machine->map_string($plaintext);note $ciphertext;
note "decrypt simple";
my $check = real_machine->map_string($ciphertext);note $check;
$plaintext =~ s{\s+}{}g;
is($check,$plaintext,
   'round tripped');