This response may be merely intuitive... AND wrong! (I am neither a cryptographer nor a particularly good mathematician.) Nonetheless, here goes...

It seems to me (YMMV . caveat above) that splitting duped chars by a variety of little used chars (or, maybe most frequently used chars) has certain merit... because it makes usage-frequency testing slightly more complex and may thus throw off any brute force using frequency testing.

#!/usr/bin/perl #!/usr/bin/perl use strict; use warnings; use 5.012; # See 910956.pl (re playfair cipher) for salt, key and encoding -- # as a follow on, modify encoding with possibility of multiple # (i,e. "varying" or "inconsistent") insertions between dup letters my @range = ("Q","V","X","Y","Z",); my $seen = ""; my $message = uc(<>); $message =~ s/[^A-Z0-9]//gi; # remove punct, etc $message =~ s/j/i/gi; $message =~ s/q/O/gi; # replace [Qq] with [Oo] $message =~ s/\s+//g; # remove spaces $message .= "X" if length($message)%2==1; # make length an even va +lue my @char = split('', $message); say "\n" . "-" x10 . "\n"; for my $char(@char) { if ($seen eq ($char)) { my $i = int(rand(4)); my $letter = $range[$i]; print $letter . $char; # recode as push to encoded arra +y for later printing } else { # as five char groups print ($char); } # recode: ditto $seen = $char; } say "\n";

The tested I/O includes (with apologies for the pre tags below)

Quoth the Raven, 'Nevermore!' ...or three (3) or four (4) words to that generally accepted effect.
----------
OUOTHTHERAVENXNEVERMOREORTHREXE3ORFOUR4WORDSTOTHATGENERALXLYACVCEPTEDEFYFECTX
^            ^         ^    ^^^^^    ^^^                ^^^^ ^^^     ^^^^   ^

# obviously, this has limitations:

The SECRET stash is located cinq feet below ground at 41.7N, 73.4W. Its key is X734ab#@17ffyj.
----------
THESECRETSTASHISLOCATEDCINOFEYETBELOWGROUNDAT417N734WITSKEYISX734AB17FVFYi
# meaning determinable from context          ^^^ ^^^
# but the new key is corrupted...                                ^^^ ^^^ ^^

In reply to Re: Playfair cipher by ww
in thread Playfair cipher by zek152

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.