Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl -w
- use strict;
- use warnings;
- use feature 'say';
- use Switch;
- use Crypt::Enigma;
- # i 5 rotori di cui se ne sceglieranno 3 - definiti in enigma.pm
- #our (@ROTOR0) = qw (e k m f l g d q v z n t o w y h x u s p a i b r c j);
- #our (@ROTOR1) = qw (a j d k s i r u x b l h w t m c q g z n p y f v o e);
- #our (@ROTOR2) = qw (b d f h j l c p r t x v z n y e i w g a k m u s q o);
- #our (@ROTOR3) = qw (e s o v p z j a y q u i r h x l n f t g k d c m w b);
- #our (@ROTOR4) = qw (v z b r g i t y u p s d n h l x a w m j q o f e c k);
- # istanzia oggetto macchina Enigma
- my $enigma = Crypt::Enigma->new();
- # Selezione dei rotori - cablaggio interno dello scambiatore - posizione iniziale rotore
- $enigma->setup('312', 'ABC', 'ERZ');
- # Scambio a to b, b to a - plugboard di Enigma, come fosse un ulteriore rotore
- $enigma->stekker('a', 'b');
- my $plainText;
- switch (defined($ARGV[0])) {
- case '' {
- $plainText='workshop at unina mmxiv'
- }
- else {
- $plainText=lc($ARGV[0])
- }
- }
- say '--> Testo in chiaro: '.$plainText;
- $plainText =~ s/[^\w]|[^\D]//g;
- my $encryptedText;
- foreach my $character (split (//,$plainText)) {
- $encryptedText.=$enigma->input($character)
- }
- say '--> Testo criptato: '.$encryptedText;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement