Skip to main content
The National Cipher Challenge

Let’s talk about the Playfair cipher

A Tale of 2 Secrets Forums T.E.M.P.E.S.T. Let’s talk about the Playfair cipher

  • This topic has 7 replies, 5 voices, and was last updated 2 months ago by _madness_.
Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #114399
    _madness_
    Participant

    With apologies to Madness I held this back as I thought it would make a very nice Christmas present, Harry

    <h1>Let’s talk about the Playfair cipher.</h1>

    Here are the rules for the usual Playfair cipher:

    1. The letter J is discarded or merged with I so that the letters fit into …

    2. … a 5×5 grid

    3. Plaintext letters are enciphered in pairs.

    4. If a pair contains two of the same letter, it is broken up by inserting an X between them. And if the text ends in an unpaired letter, an X is added there, too.

    5. When two letters appear on the same row of the grid, each is enciphered to the letter immediately to its right (with wrap-around).

    6. When two letters appear in the same column, each is enciphered to the letter immediately below it (with wrap-around).

    7. When two letters do not share a row or column, they are enciphered to the other corners of the box they make, so that each is enciphered to the other corner on the same row.

    We can detect that a Playfair cipher was used by noticing that J is missing, and that there is a pattern in the index of coincidence with a period of 2. The pattern is not as apparent as with the Vigenère cipher, however. These indicators could also point to a bifid cipher, but oh well.

    Here are some examples from old competitions that you can practice on:

    Now, we can ask: how can we modify the cipher? I gave you seven rules above, so there must be at least six ways to change things up. Here are some examples:

    Instead of J, remove a different letter (usually Z [this letter is pronounced “zee”; anyone who says “zed” without also calling Y “ypsilon” is hypocriticallacioustic and inconsistent; at least the French have the decency to say “i grec”; what do the Germans call it? “gresche i”?; the british should be glad that America took their language and fixed it, including embiggening the vocabulary]). Here are two that keep J and remove Z:

    Use a different grid. If we add digits, we can use larger grids, and even some not square. Here are some:

    • 2002 13 uses a 6×6 grid
    • 2002 14 uses a 9×4 grid
    • I saw one recently with a 5×6 grid. If the owner of that text wants to put it in the thread, OK.
    • The grid could be some nonrectangular thing. I saw one recently on a grid with three directions. If the owner of that one wants to post it, then OK.

      Pairs of the same letter could be handled differently. For example, we could keep them as double letters (no padding with X) and encrypt to the letter in the grid that is down and to the right (with wrap-around). Or, a different letter could be used to break up doubles.

      Rule 5 could be changed to shift left, up, or down.

      Rule 6 could be changed to shift right, left, or up.

      Here is an example that used a 6×6 grid and modifications to rules 5 and 6, and uses zero (0) as the padding letter:

      2021 10B

      Rule 7 could be changed to swap the ciphertext letters of each pair.

      Can anyone think of any other ways to modify the cipher?

    #114957
    Crackerjack_404
    Participant

    I somehow completely missed when this post was released, naively I had assumed forum posts were strictly chronological, but clearly that’s not always the case!

    A lot of the variants that come to mind seem to push Playfair toward the Bifid/Trifid other square cipher side, but one thing that feels particularly interesting is breaking the assumption that digraphs are processed independently and in order

    Before encryption you could swap the letters of every odd (or even) numbered digraph or apply different rules depending on the digraph index. Something like using the standard Playfair corner/rectangle rule for odd digraphs and then swapping the ciphertext letters for even digraphs. The resulting text could still hint Playfair with the missing letters/paired structure/reasonable frequencies, but the digram distribution would be asymmetric. Lots of ways to play around with parity and turn it into some form of polyalphabetic digraph cipher, without moving into the row/column recombination like we have with bifid.

    I also wonder how practical it would be to fill the grid via a path. I was watching a Numberphile video on knight’s tours earlier and that seems like a pretty (evil) option. You could choose a starting square for the grid size, precompute a knight’s tour that visits every square exactly once, then write the keyword letters along that tour path and continue filling the remaining alphabet in the same order. The encryption rules themselves wouldn’t change, but grid reconstruction would suddenly become much more painful.

    Funnily enough, while thinking about path based grid fillings I realised that the thing I was imagining has a name – boustrophedon. I had absolutely no idea this word existed until about five minutes ago, but apparently it’s the very respectable term for “filling in a row right to left and from left to right in alternate lines” (like an ox ploughing a field).

    I feel obliged to note that this may be the most passionate discussion of the letter Z I’ve seen, turns out removing a letter from the grid seems straightforward until you realise it also requires linguistic consistency across multiple languages. I suppose I’ll be saying “zee” now, for the sake of consistency if nothing else. Thank you @the_cryptographer_formerly_known_as_madness for posting this!

    (I’m quietly hoping this doesn’t inspire too many future evil ideas for ciphers, but in any case, Harry’s the boss and is free to inflict whatever flavour of cryptographic suffering he wishes. I’m just mere mortal and making suggestions and accidentally learning new words like boustrophedon…)

    #114967
    Puzzling_Pelican
    Participant

    This has been buried in the forums. I don’t think enough people have seen this gem of a Christmas present.

    Thank you Madness for this post, it was truly a treat to read.

    For anyone curious about how a Playfair can have a non-rectangular grid, the ciphertext Madness mentioned is 10B from my challenge (you can find this in the ‘Daily Cipher’ thread).

    As for other ways of modifying the cipher:
    – Rule 3 can be changed, the challenge I mentioned above uses triplets.
    – Harry’s new favorite method: put playing cards in the grid!
    – The grid can change during encryption, kind of autokey style.

    I still have an extra plaintext for my challenge after 10B and might use a combination of the last two modifications to make a cipher even harder than the ‘non-rectangular’ playfair I used for 10B.

    #115056
    upsidedown
    Participant

    @Puzzling_Pelican one idea for how the grid could change during encryption: you could use a 3×3×3 cube “grid” (27 letter alphabet), using sensible 3D versions of the playfair rules, then use Rubik’s cube style rules for updating the grid. If two letters are coplanar, rotate that plane by τ/4 clockwise/anticlockwise (depending on which way round the letters occur).

    Updating the grid reminds me of the rather cute idea of the Hutton cipher variation on the Vigenere. Harry

    #115061
    F6EXB_the_frenchy
    Participant

    I searched online to find out what Hutton’s figure is.
    Has it been broken?

    Yes, through a very clever use of classical techniques and a corpus search, but I think it might still be open whether it can be broken if the plaintext is sufficiently novel. Perhaps someone here has an idea? Harry

    #115119
    Puzzling_Pelican
    Participant

    @upsidedown
    That is truly an interesting idea and I would really love to see it become an actual cipher.
    Over the past few years, I have tried and failed to come up with consistent rules for a 3D Playfair. If you have an idea on how to achieve this, please post it to your “extracurricular challenges” thread (I greatly enjoyed breaking the first three).

    Ultimately, I have decided to go simple and just switch the two plaintext cards in the grid after every step. Although it feels too simple, I found that a small change in the key would produce gibberish after around 10 cards. I hope to post the ciphertext in a few days, enough to give me time to try break it myself and improve any weaknesses I find.

    #115134
    upsidedown
    Participant

    @Puzzling_Pelican though I have not solved your 10B, I gather that it encrypts three letters at a time, which understandably complicates the playfair rules. My Rubik’s-style cipher is a lot easier to make 3D rules for, because it only encrypts pairs at a time. There are three cases:

    1. the letters lie on a line parallel to the x, y, or zed axis: in this case move each letter one place (mod 3) up/forward along the shared line.

    2. the letters are two opposing corners of a rectangle in a plane (xy, yz or zx): map each letter to the opposing corner in the rectangle.

    3. the letters are opposing corners of a cuboid: map each letter to its opposite at the same zed coordinate.

    Another idea I had was to omit the center of the 3x3x3 grid, leaving 26 small cubes which matches a physical Rubik’s cube; the cipher could then be operated by hand by drawing each letter of the alphabet on the 1, 2, or 3 faces of the smaller cubes and physically operating the Rubik’s cube.

    Maybe the rules could be refined to be more easily followed by hand.

    Might try this out and see how well it works.

    #115138
    _madness_
    Participant

    Guys,
    I think there is already a grid-based cipher that swaps letters after each letter is enciphered, and it might by called Handycipher or LC4.

    And if anyone cares, there is a paper out there somewhere called “Breaking the second Hutton challenge”, or some nonsense like that. I think it explains Hutton’s cipher and some ideas about analyzing it.

    #115145
    F6EXB_the_frenchy
    Participant

    I just downloaded this article, but I’m not sure I can understand it. The author seems to be an expert in cryptology and has written numerous articles and books.

    #115149
    upsidedown
    Participant

    LC4 looks interesting. Much simpler and faster to use than other modern hand ciphers. Thanks for the paper, will give it a read.

    #115162
    _madness_
    Participant

    @F6EXB_the_frenchy I assure you that the author of that paper barely knew what he was doing before he started.

Viewing 11 posts - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.
Report a problem