# Is Caesar cipher perfectly secret?

The only time a shift cipher considers to be perfectly secure is when used on a single letter of plaintext and no more. Having that in mind, we can say it is certainly not perfectly secure.

Caesar cipher is perfectly secret only in the special case with the assumption that 26 keys are used in equal probability. Suppose that we have a plaintext of 50 characters long if each key for each character is chosen equiprobably then you end with 26^50 possible keys.

That is my answer, is it correct?

• Yes, you are describing the en.wikipedia.org/wiki/Vigen%C3%A8re_cipher Commented Nov 15, 2020 at 14:38
• More specifically, if you use the same shift for every character, it's a Caesar Cipher. if you use a series of shifts (of a shorter length than the message), and repeat after you reach the end, it's a Vigenère Cipher. If you have an infinite series of shifts (or enough that you never reuse an entry (across all messages)), it's a one time pad.
– Ray
Commented Nov 15, 2020 at 15:42
• I was confused what "26 keys" meant. I think you meant "26 possible values for each key character".
– Buge
Commented Nov 16, 2020 at 8:52
• It's worth noting I think with the one time pad that you have 26^50 possible keys, but it is impossible to brute force with any theoretical technology. Without the actual keys, the letters could be anything. 'AIPXKAMZIQNO' could be 'ATTACKATDAWN', but it could just as easily be 'ATTACKATNOON' or 'SURRENDERNOW' Commented Nov 17, 2020 at 5:58

And don't agree with kelalaka's answer that the key should be defined on the bits. If you don't respect the number of letters in the set and take 5 bits = 32 key values, then the letters of the original message will be moved not uniformly. $$(P + K) \mod 26$$ will produce not uniform output, because the probability that (P + K) mod 26 = P (or P+1 ... P+5) is twice the probability of P+6 ... P+25. When we consider any letter X in the encrypted message, then the probability that the original letter is one of {X-5, X-4, X-3, X-2, X-1, X} is 2/32, and the probability for other letters is 1/32.