Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. 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 am curious - If I had a text that I encrpyted with an affine cipher, would superencrypting with another affine cipher (after the first) increase the mathematical security in the final answer?

What if we encrpyted with affine first, then shift?

I think just two shifts would not increase security but I am not sure about these other two scenarios.

share|cite|improve this question
up vote 0 down vote accepted

Well a shift is a type of affine cipher (just take $a=1$).

Let's look at what happens when we combine two affine substitutions:

After one we will get (for $a$ coprime to 26):

$x \mapsto ax + b \,\text{ mod }\, 26$

Then the next gives (for $a'$ coprime to 26):

$ax+b \mapsto a'(ax+b) + b' = (aa')x + a'b + b'\, \text{ mod }\, n$.

Note that $aa'$ will also be coprime to $n$ and so we just get another affine substitution! Doing multiple affine subs just gives another affine sub.

share|cite|improve this answer
I think I see why an affine, then a shift would be the same. 3x+3 is and shift of +3 is the same as affine of 3x+6 – Jackson Hart Feb 25 '12 at 22:07
Yes, and you would get something different if you shifted first. – fretty Feb 25 '12 at 22:13
But it isnt mathematically more secure? – Jackson Hart Feb 25 '12 at 22:25
No, you have just got another of the type of cipher you started with and the key is still as likely to be a given possibility as it was before. – fretty Feb 25 '12 at 22:47

The composition of two affine ciphers is another affine cipher, so composing them is not going to increase security. At least that's if the modulus is the same.

If the moduli are different, the composition would be slightly more complex than a simple affine cipher, and thus possibly represent an "increase in security" -- but only because the baseline security of affine ciphers is so low.

By "shift", do you mean just an affine cipher with a multiplier of 1? If so, the same goes for that.

share|cite|improve this answer
Right, it would be a multiplier of 1. I was thinking that two affines would increase security. If we had 2x + 3 and then 3x + 4. This is not the same as 5x + 7. I tried this and it did not give the same answer. – Jackson Hart Feb 25 '12 at 22:05
Because you dont combine them by should be composing them as functions! – fretty Feb 25 '12 at 22:10
But doing $x\mapsto 2x+3$ and then $x\mapsto 3x+4$ is the same as $x\mapsto 6x+13$. – Henning Makholm Feb 25 '12 at 22:10
Also $2x+3$ doesn't define an affine sub on the usual alphabet...26 is not coprime to 2. – fretty Feb 25 '12 at 22:11
For 2 shift ciphers, I could just say that shift 1 + shift 2 = shift 3 which is just another shift – Jackson Hart Feb 25 '12 at 22:14

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.