Skip to content

Instantly share code, notes, and snippets.

@sylvia43
Last active May 9, 2016 17:09
Show Gist options
  • Save sylvia43/80fe08af4bc4ef1ca29f787ccd865c3f to your computer and use it in GitHub Desktop.
Save sylvia43/80fe08af4bc4ef1ca29f787ccd865c3f to your computer and use it in GitHub Desktop.
Matrix cipher cracking
EDU>> A=[62 32 45 0 49 33 44 21 0 47 49 26 24 15; 165 84 115 0 124 90 112 55 0 122 132 65 67 54]
EDU>> B=[-5 2; 1 1]
EDU>> A*B
EDU>> B*A
EDU>> A.dim
EDU>> size(A)
EDU>> A(1, 1)
EDU>> A(2, 14) = 45
EDU>> B*A
EDU>> char(B*A+64)
EDU>> C = [38 28 32 45 51 26 6 49 24 36 37 3; 105 70 90 120 135 65 17 127 63 93 97 9]
EDU>> A = [A,C]
EDU>> char(B*A+64)
EDU>> B
EDU>> B(2,1) = 3
EDU>> B(2,2) = -1
EDU>> char(B*A+64)
EDU>> X = [34 54 23 54 63 57 87 36 105 63 100 9 55 117 115 0 169 67 65 124 45 83 135 25 134 63 79 99 100 27 107 43 50 124 39 48 160 27 90 137 0 72 122 80 114 158 104 69 10 99 70 54 13 18 9 21 23 21 32 13 42 25 40 3 19 46 45 0 63 25 22 48 15 29 50 10 51 21 31 38 40 9 16 17 46 13 19 60 9 33 52 0 27 45 32 43 59 41 26 4 37 25 18]
EDU>> size(X)
EDU>> X = [34 54 23 54 63 57 87 36 105 63 100 9 55 117 115 0 169 67 65 124 45 83 135 25 134 63 79 99 100 27 107 43 50 124 39 48 160 27 90 137 0 72 122 80 114 158 104 69 10 99 70 54 13 18 9 21 23 21 32 13 42 25 40 3 19 46 45 0 63 25 22 48 15 29 50 10 51 21 31 38 40 9 40 16 17 46 13 19 60 9 33 52 0 27 45 32 43 59 41 26 4 37 25 18]
EDU>> X2 = vec2mat(X, 52)
EDU>> X2 = vec2mat(X, 52)
EDU>> which vec2mat
EDU>> which reshape
EDU>> X2 = transpose(reshape(X, [2, 52]))
EDU>> X2 = transpose(reshape(X, [52, 2]))
EDU>> X4 = transpose(reshape(X, [26, 4]))
EDU>> X2
EDU>> A(1)
EDU>> X2(1)
EDU>> X2(1:)
EDU>> X2(1,:)
EDU>> X2(1,:) - X2(2,:)
EDU>> X2(1,:) / X2(2,:)
EDU>> X2(1,:) ./ X2(2,:)
EDU>> K = [5 2; 0 0]
EDU>> char(K*X2+64)
EDU>> K*X2+64
EDU>> K = [2 5; 0 0]
EDU>> char(K*X2+64)
EDU>> K*X2+64
EDU>> K*X2
EDU>> char((K*X2)/26+64)
EDU>> X2
EDU>> (X2(1,:)/3) + (X2(2,:)/3)
EDU>> (X2(1,:)) + (X2(2,:))
EDU>> K = [2 -5; 0 0]
EDU>> char(K*X2+64)
EDU>> X2
EDU>> K = [2 -5; -1 3]
EDU>> char(K*X2+64)
EDU>>
Student License -- for use in conjunction with courses offered at a
degree-granting institution. Professional and commercial use prohibited.
EDU>> A=[62 32 45 0 49 33 44 21 0 47 49 26 24 15; 165 84 115 0 124 90 112 55 0 122 132 65 67 54]
A =
62 32 45 0 49 33 44 21 0 47 49 26 24 15
165 84 115 0 124 90 112 55 0 122 132 65 67 54
EDU>> B=[-5 2; 1 1]
B =
-5 2
1 1
EDU>> A*B
Error using *
Inner matrix dimensions must agree.
EDU>> B*A
ans =
20 8 5 0 3 15 4 5 0 9 19 0 14 33
227 116 160 0 173 123 156 76 0 169 181 91 91 69
EDU>> A.dim
Attempt to reference field of non-structure array.
EDU>> size(A)
ans =
2 14
EDU>> A(1, 1)
ans =
62
EDU>> A(2, 14) = 45
A =
62 32 45 0 49 33 44 21 0 47 49 26 24 15
165 84 115 0 124 90 112 55 0 122 132 65 67 45
EDU>> B*A
ans =
20 8 5 0 3 15 4 5 0 9 19 0 14 15
227 116 160 0 173 123 156 76 0 169 181 91 91 60
EDU>> char(B*A+64)
ans =
THE@CODE@IS@NO
ģ´à@í»ÜŒ@éõ››|
EDU>> C = [38 28 32 45 51 26 6 49 24 36 37 3; 105 70 90 120 135 65 17 127 63 93 97 9]
C =
38 28 32 45 51 26 6 49 24 36 37 3
105 70 90 120 135 65 17 127 63 93 97 9
EDU>> A = [A,C]
A =
Columns 1 through 22
62 32 45 0 49 33 44 21 0 47 49 26 24 15 38 28 32 45 51 26 6 49
165 84 115 0 124 90 112 55 0 122 132 65 67 45 105 70 90 120 135 65 17 127
Columns 23 through 26
24 36 37 3
63 93 97 9
EDU>> char(B*A+64)
ans =
THE@CODE@IS@NOT@TOO@DIFFIC
ģ´à@í»ÜŒ@éõ››|Ï¢ºåú›Wð—ÁÆL
EDU>> B
B =
-5 2
1 1
EDU>> B(2,1) = 3
B =
-5 2
3 1
EDU>> B(2,2) = -1
B =
-5 2
3 -1
EDU>> char(B*A+64)
ans =
THE@CODE@IS@NOT@TOO@DIFFIC
ULT@WITH@SOME@INFORMATION@
EDU>> X = [34 54 23 54 63 57 87 36 105 63 100 9 55 117 115 0 169 67 65 124 45 83 135 25 134 63 79 99 100 27 107 43 50 124 39 48 160 27 90 137 0 72 122 80 114 158 104 69 10 99 70 54 13 18 9 21 23 21 32 13 42 25 40 3 19 46 45 0 63 25 22 48 15 29 50 10 51 21 31 38 40 9 16 17 46 13 19 60 9 33 52 0 27 45 32 43 59 41 26 4 37 25 18]
X =
Columns 1 through 22
34 54 23 54 63 57 87 36 105 63 100 9 55 117 115 0 169 67 65 124 45 83
Columns 23 through 44
135 25 134 63 79 99 100 27 107 43 50 124 39 48 160 27 90 137 0 72 122 80
Columns 45 through 66
114 158 104 69 10 99 70 54 13 18 9 21 23 21 32 13 42 25 40 3 19 46
Columns 67 through 88
45 0 63 25 22 48 15 29 50 10 51 21 31 38 40 9 16 17 46 13 19 60
Columns 89 through 103
9 33 52 0 27 45 32 43 59 41 26 4 37 25 18
EDU>> size(X)
ans =
1 103
EDU>> X = [34 54 23 54 63 57 87 36 105 63 100 9 55 117 115 0 169 67 65 124 45 83 135 25 134 63 79 99 100 27 107 43 50 124 39 48 160 27 90 137 0 72 122 80 114 158 104 69 10 99 70 54 13 18 9 21 23 21 32 13 42 25 40 3 19 46 45 0 63 25 22 48 15 29 50 10 51 21 31 38 40 9 40 16 17 46 13 19 60 9 33 52 0 27 45 32 43 59 41 26 4 37 25 18]
X =
Columns 1 through 22
34 54 23 54 63 57 87 36 105 63 100 9 55 117 115 0 169 67 65 124 45 83
Columns 23 through 44
135 25 134 63 79 99 100 27 107 43 50 124 39 48 160 27 90 137 0 72 122 80
Columns 45 through 66
114 158 104 69 10 99 70 54 13 18 9 21 23 21 32 13 42 25 40 3 19 46
Columns 67 through 88
45 0 63 25 22 48 15 29 50 10 51 21 31 38 40 9 40 16 17 46 13 19
Columns 89 through 104
60 9 33 52 0 27 45 32 43 59 41 26 4 37 25 18
EDU>> X2 = vec2mat(X, 52)
Undefined function 'vec2mat' for input arguments of type 'double'.
EDU>> X2 = vec2mat(X, 52)
Undefined function 'vec2mat' for input arguments of type 'double'.
EDU>> which vec2mat
'vec2mat' not found.
EDU>> which reshape
built-in (C:\Program Files\MATLAB\R2014a\toolbox\matlab\elmat\@logical\reshape) % logical method
EDU>> X2 = transpose(reshape(X, [2, 52]))
X2 =
34 54
23 54
63 57
87 36
105 63
100 9
55 117
115 0
169 67
65 124
45 83
135 25
134 63
79 99
100 27
107 43
50 124
39 48
160 27
90 137
0 72
122 80
114 158
104 69
10 99
70 54
13 18
9 21
23 21
32 13
42 25
40 3
19 46
45 0
63 25
22 48
15 29
50 10
51 21
31 38
40 9
40 16
17 46
13 19
60 9
33 52
0 27
45 32
43 59
41 26
4 37
25 18
EDU>> X2 = transpose(reshape(X, [52, 2]))
X2 =
Columns 1 through 22
34 54 23 54 63 57 87 36 105 63 100 9 55 117 115 0 169 67 65 124 45 83
13 18 9 21 23 21 32 13 42 25 40 3 19 46 45 0 63 25 22 48 15 29
Columns 23 through 44
135 25 134 63 79 99 100 27 107 43 50 124 39 48 160 27 90 137 0 72 122 80
50 10 51 21 31 38 40 9 40 16 17 46 13 19 60 9 33 52 0 27 45 32
Columns 45 through 52
114 158 104 69 10 99 70 54
43 59 41 26 4 37 25 18
EDU>> X4 = transpose(reshape(X, [26, 4]))
X4 =
Columns 1 through 22
34 54 23 54 63 57 87 36 105 63 100 9 55 117 115 0 169 67 65 124 45 83
79 99 100 27 107 43 50 124 39 48 160 27 90 137 0 72 122 80 114 158 104 69
13 18 9 21 23 21 32 13 42 25 40 3 19 46 45 0 63 25 22 48 15 29
31 38 40 9 40 16 17 46 13 19 60 9 33 52 0 27 45 32 43 59 41 26
Columns 23 through 26
135 25 134 63
10 99 70 54
50 10 51 21
4 37 25 18
EDU>> X2
X2 =
Columns 1 through 22
34 54 23 54 63 57 87 36 105 63 100 9 55 117 115 0 169 67 65 124 45 83
13 18 9 21 23 21 32 13 42 25 40 3 19 46 45 0 63 25 22 48 15 29
Columns 23 through 44
135 25 134 63 79 99 100 27 107 43 50 124 39 48 160 27 90 137 0 72 122 80
50 10 51 21 31 38 40 9 40 16 17 46 13 19 60 9 33 52 0 27 45 32
Columns 45 through 52
114 158 104 69 10 99 70 54
43 59 41 26 4 37 25 18
EDU>> A(1)
ans =
62
EDU>> X2(1)
ans =
34
EDU>> X2(1:)
X2(1:)
|
Error: Unbalanced or unexpected parenthesis or bracket.
EDU>> X2(1,:)
ans =
Columns 1 through 22
34 54 23 54 63 57 87 36 105 63 100 9 55 117 115 0 169 67 65 124 45 83
Columns 23 through 44
135 25 134 63 79 99 100 27 107 43 50 124 39 48 160 27 90 137 0 72 122 80
Columns 45 through 52
114 158 104 69 10 99 70 54
EDU>> X2(1,:) - X2(2,:)
ans =
Columns 1 through 22
21 36 14 33 40 36 55 23 63 38 60 6 36 71 70 0 106 42 43 76 30 54
Columns 23 through 44
85 15 83 42 48 61 60 18 67 27 33 78 26 29 100 18 57 85 0 45 77 48
Columns 45 through 52
71 99 63 43 6 62 45 36
EDU>> X2(1,:) / X2(2,:)
ans =
2.6511
EDU>> X2(1,:) ./ X2(2,:)
ans =
Columns 1 through 13
2.6154 3.0000 2.5556 2.5714 2.7391 2.7143 2.7188 2.7692 2.5000 2.5200 2.5000 3.0000 2.8947
Columns 14 through 26
2.5435 2.5556 NaN 2.6825 2.6800 2.9545 2.5833 3.0000 2.8621 2.7000 2.5000 2.6275 3.0000
Columns 27 through 39
2.5484 2.6053 2.5000 3.0000 2.6750 2.6875 2.9412 2.6957 3.0000 2.5263 2.6667 3.0000 2.7273
Columns 40 through 52
2.6346 NaN 2.6667 2.7111 2.5000 2.6512 2.6780 2.5366 2.6538 2.5000 2.6757 2.8000 3.0000
EDU>> K = [5 2; 0 0]
K =
5 2
0 0
EDU>> char(K*X2+64)
ans =
ĄŲÅŸƩƇȳĎʡƭʄsŹ˥˙@ЋǁƱ̌Ŀș͇Ñ̈́ƥȉɻʄÙʧķŜ̈ĝŖϘÙɄ͕@Ǟ˼ȐːόʚǍzɹǐŲ
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
EDU>> K*X2+64
ans =
Columns 1 through 11
260 370 197 376 425 391 563 270 673 429 644
64 64 64 64 64 64 64 64 64 64 64
Columns 12 through 22
115 377 741 729 64 1035 449 433 780 319 537
64 64 64 64 64 64 64 64 64 64 64
Columns 23 through 33
839 209 836 421 521 635 644 217 679 311 348
64 64 64 64 64 64 64 64 64 64 64
Columns 34 through 44
776 285 342 984 217 580 853 64 478 764 528
64 64 64 64 64 64 64 64 64 64 64
Columns 45 through 52
720 972 666 461 122 633 464 370
64 64 64 64 64 64 64 64
EDU>> K = [2 5; 0 0]
K =
2 5
0 0
EDU>> char(K*X2+64)
ans =
ÅƛĕıěƎÉǤĻǐačȐȇ@ˍŃİȨåŷɈ¤ɋħŹDŽǐ£ǞæùȞÏÿʬ£ƙɖ@ŗȕƀǻʣǝŌhƿʼnĆ
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
EDU>> K*X2+64
ans =
Columns 1 through 22
197 262 155 277 305 283 398 201 484 315 464 97 269 528 519 64 717 323 304 552 229 375
64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64
Columns 23 through 44
584 164 587 295 377 452 464 163 478 230 249 542 207 255 684 163 409 598 64 343 533 384
64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64
Columns 45 through 52
507 675 477 332 104 447 329 262
64 64 64 64 64 64 64 64
EDU>> K*X2
ans =
Columns 1 through 22
133 198 91 213 241 219 334 137 420 251 400 33 205 464 455 0 653 259 240 488 165 311
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Columns 23 through 44
520 100 523 231 313 388 400 99 414 166 185 478 143 191 620 99 345 534 0 279 469 320
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Columns 45 through 52
443 611 413 268 40 383 265 198
0 0 0 0 0 0 0 0
EDU>> char((K*X2)/26+64)
ans =
EGCHIHLEPIOAGQQ@YIIRFKTCTHLNOCOFGREGWCMT@JRLQWOJANJG
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
EDU>> X2
X2 =
Columns 1 through 22
34 54 23 54 63 57 87 36 105 63 100 9 55 117 115 0 169 67 65 124 45 83
13 18 9 21 23 21 32 13 42 25 40 3 19 46 45 0 63 25 22 48 15 29
Columns 23 through 44
135 25 134 63 79 99 100 27 107 43 50 124 39 48 160 27 90 137 0 72 122 80
50 10 51 21 31 38 40 9 40 16 17 46 13 19 60 9 33 52 0 27 45 32
Columns 45 through 52
114 158 104 69 10 99 70 54
43 59 41 26 4 37 25 18
EDU>> (X2(1,:)/3) + (X2(2,:)/3)
ans =
Columns 1 through 16
15.6667 24.0000 10.6667 25.0000 28.6667 26.0000 39.6667 16.3333 49.0000 29.3333 46.6667 4.0000 24.6667 54.3333 53.3333 0
Columns 17 through 32
77.3333 30.6667 29.0000 57.3333 20.0000 37.3333 61.6667 11.6667 61.6667 28.0000 36.6667 45.6667 46.6667 12.0000 49.0000 19.6667
Columns 33 through 48
22.3333 56.6667 17.3333 22.3333 73.3333 12.0000 41.0000 63.0000 0 33.0000 55.6667 37.3333 52.3333 72.3333 48.3333 31.6667
Columns 49 through 52
4.6667 45.3333 31.6667 24.0000
EDU>> (X2(1,:)) + (X2(2,:))
ans =
Columns 1 through 27
47 72 32 75 86 78 119 49 147 88 140 12 74 163 160 0 232 92 87 172 60 112 185 35 185 84 110
Columns 28 through 52
137 140 36 147 59 67 170 52 67 220 36 123 189 0 99 167 112 157 217 145 95 14 136 95 72
EDU>> K = [2 -5; 0 0]
K =
2 -5
0 0
EDU>> char(K*X2+64)
ans =
CRACKING@A@CODE@WITHOUT@MUCH@INFORMATION@IS@MUCH@MOR
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
EDU>> X2
X2 =
Columns 1 through 27
34 54 23 54 63 57 87 36 105 63 100 9 55 117 115 0 169 67 65 124 45 83 135 25 134 63 79
13 18 9 21 23 21 32 13 42 25 40 3 19 46 45 0 63 25 22 48 15 29 50 10 51 21 31
Columns 28 through 52
99 100 27 107 43 50 124 39 48 160 27 90 137 0 72 122 80 114 158 104 69 10 99 70 54
38 40 9 40 16 17 46 13 19 60 9 33 52 0 27 45 32 43 59 41 26 4 37 25 18
EDU>> K = [2 -5; -1 3]
K =
2 -5
-1 3
EDU>> char(K*X2+64)
ans =
CRACKING@A@CODE@WITHOUT@MUCH@INFORMATION@IS@MUCH@MOR
E@DIFFICULT@BUT@THAT@DOES@NOT@MEAN@IT@IS@IMPOSSIBLE@
EDU>>
@sylvia43
Copy link
Author

sylvia43 commented May 9, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment