Cryptography Stack Exchange is a question and answer site for software developers, mathematicians and others interested in cryptography. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I was just studying the Playfair cipher and from what I've understood, it is just a slightly better version of a Caesar cipher, in that it isn't actually mono-alphabetic but rather the 'digrams' are mono-alphabetic. I believe that since it offers a larger combination i.e 26*26=676 digrams, it is better than a Caesar Cipher which would give us a maximum of twenty-six keys. So does this mean that the Playfair Cipher have 676 keys including the duplicate or is it larger than that ?

share|improve this question
How would "Caesar Cipher (..have..) a maximum of six keys"? Or is that 26? – fgrieu Sep 18 '12 at 11:54
Sorry, I seem to have missed the word 'twenty' in there. You are correct, it should be 26 – GamingX Sep 18 '12 at 23:40
up vote 7 down vote accepted

When we consider that a Playfair key consists of the alphabet (reduced to 25 letters) spread on a 5x5 square, that's $25!$ keys (another formulation consider any string to be a key; then strings leading to the same square are equivalent keys).

The rules of Playfair are such that any rotation of the lines in the square, and any rotation of its columns, lead to an equivalent key (in other words, the square reduce to a torus). It can be proven conclusively that there are no other equivalent keys (note: a transposition of line/columns leads to a key such that 200 out of 600 digrams with distinct letters are mapped to the same diagram as for the original key, and the other 400 are mapped to the digram obtained by exchanging the two letters in the digram mapped by the original key; also, an horizontal or [resp. and] vertical mirroring of the square leaves 500 (resp. 400) digrams invariants; these are near-equivalent related keys, but not equivalent keys).

I conclude Playfair has $25!/{5^2}=620448401733239439360000\approx2^{79}$ distinct keys classes (a 79-bit-key cipher). At least another source agrees.

This is much less than an arbitrary permutation of digrams with distinct letters, which allows $(25\cdot24)!\approx2^{4678}$ keys.

If that's a homework question, I find it excellent to illustrate the notions of equivalent keys, key space, and why a big keyspace is not sufficient for security.

share|improve this answer
I believe you've given the correct answer. Thanks! – GamingX Sep 18 '12 at 23:42
@Syed, FYI, as a new user here you may not be aware of this. You can click the check mark next to an answer to accept it. That helps other users know which answer you determined to be the best (plus it gives extra rep points to the author) – mikeazo Sep 19 '12 at 0:04

Counting duplicate keys, it would be $25!$ (remember i=j in playfair). Basically the key is the 5x5 square. There are $25!$ permutations of the $25$ characters which populate that square.

share|improve this answer
How about if we ignore the duplicate keys ? – GamingX Sep 12 '12 at 23:27
Thanks to you too. You did give me the correct answer, but I was also looking for the number of unique keys too. – GamingX Sep 18 '12 at 23:43
@Syed, I completely understand. fgrieu took advantage of my procrastination :) – mikeazo Sep 19 '12 at 0:02

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.