Ask your own question, for FREE!
Mathematics 15 Online
OpenStudy (anonymous):

The message PJXFJ SWJNX JMRTJ FVSUJ OOJWF OVAJR WHEOF JRWJO DJFFZ BJF was encrypted using an affine transformation C=aP + b mod {26}. Use frequencies of letters to determine the values of $a$ and $b$. What is the plain text message?

OpenStudy (kinggeorge):

So I haven't done too much of this before, but the first thing we need to know is what letters are the most common in general speech. Then you need to find which letters appear the most in the ciphertext. Do you have some sort of chart for which letters are the most common?

OpenStudy (anonymous):

Correct, i have that j is most occuring followed by f. Which gives me that j most likely equal e and f equals t.

OpenStudy (anonymous):

This in turn gives me two equations 9=4a+b & 5= 19a+b

OpenStudy (anonymous):

this is in modulo 26

OpenStudy (kinggeorge):

Looks reasonable so far.

OpenStudy (anonymous):

This is where I get confused because I need to somehow find the inverse and so on. Nothing is clear to me

OpenStudy (anonymous):

I am not sure what I am finding the inverse of?

OpenStudy (kinggeorge):

Well, why don't we try solving like a regular old system of equations.\[9\equiv4a+b\pmod{26}\implies b\equiv9-4a\pmod{26}\]Plug this into the other equation, and we get\[5\equiv19a+9-4a\pmod{26}\]Simplifying a bit, this means\[5\equiv15a+9\pmod{26}\implies11a\equiv4\pmod{26}\]Following this so far?

OpenStudy (anonymous):

Yes

OpenStudy (kinggeorge):

This is where we find he inverse of \(11\) modulo 26. There's a couple methods to finding it. Are you familiar with any of them?

OpenStudy (anonymous):

Every time I find a way it is the wrong one. I am definitely having trouble with inverses but I am most comfortable with euclid algorithm

OpenStudy (kinggeorge):

That's a nice straightforward way.

OpenStudy (kinggeorge):

With the euclidean algorithm, we get\[26=2\cdot11+4\]\[11=2\cdot4+3\]\[4=3\cdot1+1\]Now we back-substitute.

OpenStudy (kinggeorge):

We have\[1=4-3\]\[3=11-2\cdot4\]\[4=26-2\cdot11\]So\[\begin{aligned} 1&=4-3\\ &=(26-2\cdot11)-(11-2\cdot4)\\ &=26-3\cdot11+2\cdot4\\ &=26-3\cdot11+2(26-2\cdot11)\\ &=3\cdot26-7\cdot11 \end{aligned}\]So the inverse of \(11\) modulo \(26\) should be \(-7\), or \(19\).

OpenStudy (anonymous):

That looks so much simpler and organized than what I have done when trying to do this. No wonder I am having trouble. Now, does this mean that 19 is a?

OpenStudy (kinggeorge):

We have one last thing to work out. We know that\[11\cdot(-7)\equiv1\pmod{26}\]but we want to solve\[11a\equiv4\pmod{26}.\]But solving for \(x\) is easy, as we only need to multiply by 4. So\[11\cdot(-7)\cdot4\equiv1\cdot4\equiv4\pmod{26}.\]Then\[-7\cdot4=-28\equiv24\pmod{26}\]So \(a=24\), or \(-2\) since that's probably easier to work with.

OpenStudy (anonymous):

I do not see how you get 24

OpenStudy (kinggeorge):

\(24\) simply comes from the fact \(-28\equiv24\pmod{26}\) since \(-28=24-2\cdot26\).

OpenStudy (anonymous):

Okay. So now that I have this what should I do next?

OpenStudy (kinggeorge):

Now you need to plug this back into your original equations to solve for \(b\).

OpenStudy (anonymous):

Do you I lug in 24? or -2?

OpenStudy (kinggeorge):

Either will work, but \(-2\) will probably result in an easier computation.

OpenStudy (anonymous):

Okay, so I have that b =17.

OpenStudy (kinggeorge):

Right. So the affine transformation should be given by\[C=-2P+17\pmod{26}\]Or if you're only allowed to use positive numbers in the final solution, you could write\[C=24A+17\pmod{26}\]

OpenStudy (kinggeorge):

Sorry, the last equation should be\[C=24P+17\pmod{26}\]

OpenStudy (anonymous):

Okay. So now I plug in my first letter which is p =15. I have 15=24P+17, P=1?

OpenStudy (anonymous):

You're solving for the plain text not the ciphertext.

OpenStudy (anonymous):

C=P is the first letter of the cipher text, correct?

OpenStudy (kinggeorge):

\(P=1\) seems like it works.

OpenStudy (anonymous):

But what do I do when I get to A which is valued at 0. I would have a fraction?

OpenStudy (kinggeorge):

Something seems off to me.

OpenStudy (anonymous):

BEKGE ECK EAME GLE EG LEA FG EAE HEGGJ IEG

OpenStudy (anonymous):

Which is clearly wrong.

OpenStudy (anonymous):

I feel like we are on the right track just missing something. Maybe it is not the obvious? Would there be another way?

OpenStudy (anonymous):

The missing data here is the frequency information. The idea is to use common frequencies of letters in the English language to aid solving the scale and shift constants.

OpenStudy (anonymous):

i did this, unless i was given incorrect information

OpenStudy (kinggeorge):

I believe @alchemista is probably right. In this particular case, I don't think e is sent to j, and t is sent to f. I'm afraid it has to be something else.

OpenStudy (kinggeorge):

The math I worked out is definitely correct. However, at the end, we need to get a value for \(a\) that is relatively prime to \(26\). So what's your second guess for which letters map to j and f? Note that we don't have to change both. Just one.

OpenStudy (anonymous):

Are there many 5 letter words JMRTJ that start and end with e?

OpenStudy (anonymous):

err, I mean I can't think of any right now.

OpenStudy (anonymous):

It's not a 5-letter word, it's two words

OpenStudy (anonymous):

yes its not a 5 letter word, it could be but it is most likely not

OpenStudy (anonymous):

*PJXFJ is two words, JMRTJ is part of a longer word

OpenStudy (anonymous):

it could be the end of the word before it or the beginning of another word. I think!

OpenStudy (kinggeorge):

So to actually decrypt this, you need to take another guess at what might get sent to j, and what might get sent to f. I think it's probably a safe bet to keep e going to j. But what about f? What are some of the most common letters beside e and t?

OpenStudy (anonymous):

R, N, I are the third most used

OpenStudy (anonymous):

*S goes F

OpenStudy (kinggeorge):

I think I'm going to agree with @eashy here. In general practice, you would have to guess and check a bunch of different possible combinations, you should probably just send S to F and E to J, and solve from there.

OpenStudy (anonymous):

(12, 'J') (7, 'F') (5, 'O') (4, 'W') e 12.702% t 9.056% a 8.167% o 7.507% i 6.966%

OpenStudy (anonymous):

F is the second most common. It seems very unlikely that it would be S if it followed frequencies in english.

OpenStudy (anonymous):

actually you could do T->O instead

OpenStudy (anonymous):

these problems are not really meant to be solved by hand though, the best way is algorithmically

OpenStudy (anonymous):

http://ptrow.com/perl/calculator.pl ,y professor gave us this website but I cannot see how to do the affine function with this calculator

OpenStudy (kinggeorge):

If you have a short message, the frequencies of letters in the message won't model the real-life frequencies very well. You need a large sample size to start seeing those.

OpenStudy (anonymous):

It just seems like so much work to have to keep trying doing different calculations, especially since we need to find the inverses

OpenStudy (anonymous):

KingGeorge, obviously as the sample size increase the distribution will converge toward the one listed on wikipedia. However, this is the best you have to work with. Other than that its just guess and check.

OpenStudy (kinggeorge):

Well, if you do everything by hand it can get quite tedious. But plug some numbers in a calculator, and it goes by in a flash.

OpenStudy (anonymous):

So 9, 25 does work

OpenStudy (anonymous):

A = 9 b = 25

OpenStudy (anonymous):

Yay for brute force: http://pastebin.com/4L2WmJTZ

OpenStudy (anonymous):

[A=9 b=25]: WEUSE FREQU ENCIE SOFLE TTERS TODEC RYPTS ECRET MESSA GES

OpenStudy (anonymous):

that makes sense

OpenStudy (kinggeorge):

Brute forcing decryption is definitely the best way to go. Always. :P

OpenStudy (anonymous):

Wish I could do that. But I still need an explanation because this is for a number theory class

OpenStudy (anonymous):

Just justify it after the fact by using the original technique. Solve the system of equations setting the expected letters using our ill gotten knowledge.

OpenStudy (kinggeorge):

Right. Same process as we did before, just the equations\[9=4a+b\]and\[5=20a+b\]instead.

OpenStudy (anonymous):

so it is s not t

OpenStudy (anonymous):

I have to say it was mean of them to throw in the spaces to possibly confuse you.

OpenStudy (anonymous):

5=20a+b or 5=18a+b

OpenStudy (anonymous):

Why blocks of 5 letters? Mysterious...

OpenStudy (kinggeorge):

In most ciphertexts I've seen, it's usually broken up into 5 block chunks. And possibly adding some junk text at the very end to ensure that. Right 5=18a+b. Sorry about that. It's getting late here :P

OpenStudy (anonymous):

It makes sense to have a fixed block size for a block cipher

OpenStudy (anonymous):

okay

OpenStudy (kinggeorge):

The 5 blocks is a remnant from ciphers that require you to write out the alphabet in a 5x5 square (i and j are in the same place).

OpenStudy (anonymous):

Ah, thanks. That makes more sense.

OpenStudy (kinggeorge):

This is one of the more well-known of that form. http://en.wikipedia.org/wiki/Playfair_cipher

OpenStudy (anonymous):

Anyway, hopefully when you solve the system you get 9, 25

OpenStudy (kinggeorge):

I think polybius square is the official name.

OpenStudy (anonymous):

Not getting a=9 or b=25

OpenStudy (anonymous):

Solving the two equations, I am getting -4=14a (mod 26)

OpenStudy (anonymous):

Something is wrong here

OpenStudy (anonymous):

There is no inverse for a

OpenStudy (anonymous):

Must get some sleep now, i have classes in a couple hours. If any of you care to try again, please let me know. I do not see how to get an inverse out of these equations. Thank you for your help. Also, alchemist I see that you programming? I need some help with a very simple program (counting characters using arrays but it starts with a string and it only counts numbers 1 - 9) If interested let me know thanks.

OpenStudy (anonymous):

Try to continue from here: 15 = A*22 + b 9 = A*4 + b 6 = 18*a ....

OpenStudy (anonymous):

18*9 (mod 26) = 6

OpenStudy (anonymous):

Why 22?

OpenStudy (anonymous):

W -> P

OpenStudy (anonymous):

It works, doesn't it?

OpenStudy (anonymous):

Yes but I have to show work and I cant see how I would explain that answer

OpenStudy (anonymous):

What two equations were you using? Let me check if it is correct.

OpenStudy (anonymous):

9=4a+b and 5=18a+b

OpenStudy (anonymous):

9 * 14 (mod 26) = 22 = (26 - 4) == -4 (mod 26)

OpenStudy (anonymous):

Don't you see? -4 == 22 (mod 26)

OpenStudy (anonymous):

yes But how does that give me a=9

OpenStudy (anonymous):

9 is a possible solution, you need to solve it using the euclidean algorithm as KingGeorge demonstrated.

OpenStudy (anonymous):

Yes, I have tried but I did not try 4

OpenStudy (anonymous):

You have -4 = 14*a correct? Rewrite it as 22 = 14*a

OpenStudy (anonymous):

ok

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!