Vigenère cipher/Cryptanalysis: Difference between revisions

m
→‎{{header|Perl 6}}: eliminate temp variable
(Added Perl 6 example)
m (→‎{{header|Perl 6}}: eliminate temp variable)
Line 1,561:
}
 
my $cipher-text = .uc.subst("rx/<-[{join '',@alphabet}]>/".EVAL, '', :g) given q:to/EOD/;
MOMUD EKAPV TQEFM OEVHP AJMII CDCTI FGYAG JSPXY ALUYM NSMYH
VUXJE LEPXJ FXGCM JHKDZ RYICU HYPUS PGIGM OIYHF WHTCQ KMLRD
Line 1,581:
EOD
 
for myguess($cipher-text) -> $key {
my $text = $cipher-text.uc.subst("rx/<-[{join '',@alphabet}]>/".EVAL, '', :g);
@res.push: "Key $key\n" ~
 
"Key length {$key.chars}\n" ~
for myguess($text) -> $key {
say "Key "Plaintext {substr(mycrypt($cipher-text, $key), 0, 80)}...\n" ~;
"Key length {$key.chars}\n" ~
"Plaintext {substr(mycrypt($text, $key), 0, 80)}...\n";
}</lang>
{{out}}
2,392

edits