diff options
author | dakkar <dakkar@thenautilus.net> | 2011-08-29 18:22:24 +0100 |
---|---|---|
committer | dakkar <dakkar@thenautilus.net> | 2011-08-29 18:23:00 +0100 |
commit | c802d62a3afc99c784cfbb7ca2033930d6537555 (patch) | |
tree | 885cab58e5f1426b28f8f8899bc9e51b9d766a55 /t/simple-enigma.t | |
parent | plugboard (diff) | |
download | Enigmatic-c802d62a3afc99c784cfbb7ca2033930d6537555.tar.gz Enigmatic-c802d62a3afc99c784cfbb7ca2033930d6537555.tar.bz2 Enigmatic-c802d62a3afc99c784cfbb7ca2033930d6537555.zip |
full-machine and tests
Diffstat (limited to 't/simple-enigma.t')
-rw-r--r-- | t/simple-enigma.t | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/t/simple-enigma.t b/t/simple-enigma.t new file mode 100644 index 0000000..b2bcbdd --- /dev/null +++ b/t/simple-enigma.t @@ -0,0 +1,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'); |