Decrypting A Message

Here is an encrypted message and key matrix.

222 151 239 89 111 256 273 218 329 157 140 338 240 246 283 134 108 301 157 95 250 141 93 207 175 161 236 99 69 222 136 79 211 114 78 176 128 119 159 81 79 157 218 196 272 114 97 264 233 231 347 168 178 261 257 229 290 97 142 280 137 137 208 77 99 142 271 258 363 156 162 308 204 187 315 139 165 216

Key Matrix
3 5 2 2 2 4
2 1 5 3 1 3
? 2 5 3 3 5
? 4 5 1 3 2
4 1 4 1 2 4
4 5 4 1 1 5

Since the key matrix is a 6x6 matrix, the information in the encrypted message has to be entered into a nx6 matrix, where n depends on how many numbers you have. For example, if you have 60 numbers in your message, then the matrix will be 10x6. If there are 72 numbers, it will be 12x6, and so on.

  A B C D E F
1 Encrypted Matrix        
2 222 151 239 89 111 256
3 273 218 329 157 140 338
4 240 246 283 134 108 301
5 157 95 250 141 93 207
6 175 161 236 99 69 222
7 136 79 211 114 78 176
8 128 119 159 81 79 157
9 218 196 272 114 97 264
10 233 231 347 168 178 261
11 257 229 290 97 142 280
12 137 137 208 77 99 142
13 271 258 363 156 162 308
14 204 187 315 139 165 216

Then enter the key matrix into the spreadsheet. I suggest putting it several rows below your encryption matrix. Go ahead and put in some numbers where the question marks are.

  A B C D E F
20 Key Matrix        
21 3 5 2 2 2 4
22 2 1 5 3 1 3
23 1 2 5 3 3 5
24 2 4 5 1 3 2
25 4 1 4 1 2 4
26 4 5 4 1 1 5

Find the inverse of the key matrix. I would suggest putting it to the right of the Key Matrix, say starting in cell H21. The function for finding the inverse of a matrix A is =minverse(A), but Excel is really particular how you enter this, so follow the instructions carefully.

  1. Click in the first cell of the matrix. (cell H21)
  2. Highlight all the cells of the matrix. Since the inverse is the same size as the original matrix, it will need to be a 6x6 matrix, so highlight 6 rows and 6 columns. (cells H21:M26)
  3. Type =minverse( and then highlight the cells in the key matrix (cells A21:F26)
  4. Close the ) so the formula reads =minverse(A21:F26)
  5. Hold the shift and control keys down and press enter

If you would rather type the function instead of highlighting the key matrix, you can just type in the entire thing. You still must highlight the area where the matrix is to go before typing in the command and hold the control and shift before hitting enter when finished.

You may optionally wish to highlight the cells in the inverse, click the right mouse button, choose format, and set the format to Number with 4 decimal places. This is purely asthetic, it won't affect the calculations.

  H I J K L M
20 Inverse of Key Matrix      
21 0.1919 0.1273 -0.2926 -0.0065 0.2674 -0.1486
22 0.0756 -0.0071 -0.0446 0.0917 -0.1977 0.1098
23 -0.2674 0.1021 0.0039 0.1370 -0.0698 0.1499
24 0.3547 0.3598 -0.1066 -0.0995 -0.0814 -0.2881
25 0.1802 -0.2306 0.0988 0.1589 0.2209 -0.3450
26 -0.1221 -0.2022 0.2771 -0.2080 0.0116 0.2158

We're almost there. Now we need to multiply the original encrypted matrix by the inverse of the key matrix. The Excel command to multiply matrix A by matrix B is =mmult(A,B). Again, you must be very careful when you enter this into Excel. The product will be the same size as the original encrypted matrix, so I'll enter it to the right of the original matrix in cells H2:M14.

  1. Highlight cells H2:M14
  2. Type =mmult(
  3. highlight the original encryption matrix in cells A2:F14 and then hit the comma.
  4. highlight the inverse of the key matrix in H21:M26 and then close the ). The command now reads =mmult(A2:F14,H21:M26)
  5. Hold the control and shift keys and press enter

I've formatted all of the cells to three decimal places so it looks good here, but I don't suggest doing that just yet for your spreadsheet. I'll explain why after the table.

  H I J K L M
1 Unencrypted Matrix      
2 10.401 6.236 1.661 0.683 33.105 10.720
3 20.512 22.636 2.442 -0.388 29.047 12.085
4 19.192 20.127 -0.293 0.994 12.267 22.851
5 11.936 32.254 2.320 -0.368 17.244 -3.469
6 3.070 20.036 0.318 0.897 8.279 22.623
7 8.634 25.727 1.831 -0.291 16.035 -1.686
8 14.826 10.854 0.539 3.703 12.302 1.165
9 9.576 19.382 -0.878 2.981 15.802 20.554
10 29.157 30.054 -5.118 24.490 21.128 -10.738
11 14.866 6.218 -2.998 13.735 29.965 13.908
12 8.826 13.854 -4.461 18.703 12.302 0.165
13 21.331 26.200 -4.657 17.787 22.826 8.097
14 21.692 25.072 -5.459 26.438 23.267 -12.926

Notice the numbers aren't whole numbers between 0 and 44? That means I didn't put the right numbers in for the question marks in the key matrix. Once I get the right numbers in there, then the matrix will look much nicer.

After trying a bunch of different numbers, I found out that the right numbers to go into the key matrix were 4 and 3.

  A B C D E F
20 Key Matrix        
21 3 5 2 2 2 4
22 2 1 5 3 1 3
23 4 2 5 3 3 5
24 3 4 5 1 3 2
25 4 1 4 1 2 4
26 4 5 4 1 1 5

When I enter those numbers into the matrix, then I get this for the unencrypted matrix.

  H I J K L M
1 Unencrypted Matrix      
2 1 6E-14 16 1 20 18
3 9 15 20 0 13 21
4 19 20 1E-13 1 12 23
5 1 25 19 7E-15 2 5
6 0 18 5 1 4 25
7 -3E-14 20 15 4E-15 4 5
8 6 5 14 4 -6E-14 8
9 9 19 2E-13 3 15 21
10 14 20 18 25 -1E-13 1
11 7 1 9 14 19 20
12 3E-14 8 9 19 0 7
13 15 22 5 18 14 13
14 5 14 20 27 -1E-13 -3E-14

Those E-14 and E-13 numbers are scientific notation and basically mean 0. The only reason they're not zero is because the computer can only carry about 12 significant figures and so it shows 6E-14 instead of 0 due to a rounding error.

This is the message we wanted but now I'll tell you how to make it look even better. There is a =round(x,n) function that will round the value x to n decimal places. The round off error will always be very small, so we can safely round to three or four decimal places and still be assured that we'll get the right numbers.

Go back to the steps where you created the unencrypted matrix in cells H2:M14 and instead of entering =mmult(A2:F14,H21:M26), enter =round(mmult(A2:F14,H21:M26),4) instead. Be sure to follow the instructions about highlighting the cells first and holding the control and shift keys before pressing enter.

Now we get a matrix that looks like this.

  H I J K L M
1 Unencrypted Matrix      
2 1 0 16 1 20 18
3 9 15 20 0 13 21
4 19 20 0 1 12 23
5 1 25 19 0 2 5
6 0 18 5 1 4 25
7 0 20 15 0 4 5
8 6 5 14 4 0 8
9 9 19 0 3 15 21
10 14 20 18 25 0 1
11 7 1 9 14 19 20
12 0 8 9 19 0 7
13 15 22 5 18 14 13
14 5 14 20 27 0 0

We're ready to decode the message by converting each number back into a letter or symbol.

1 0 16 1 20 18 9 15 20 0 13 21 19 20 0 1 12 23 1 25 19 0 2 5 0 18 5 1 4 25 0 20 15 0 4 5 6 5 14 4 0 8 9 19 0 3 15 21 14 20 18 25 0 1 7 1 9 14 19 20 0 8 9 19 0 7 15 22 5 18 14 13 5 14 20 27 0 0

A patriot must always be ready to defend his country against his government.

For a bonus point, find out who said your quote. In this case, it was Edward Abbey.

Go to Math 116 homepage
Last updated: January 9, 2005 11:21 AM