Getting the encryption matrix given letters is pretty easy:CongminhTran wrote:Hey guys,
I was just wondering if any of you guys could help me with the Hill Cipher, both decryption and encryption?
For encryption, how do you make an encryption matrix given plaintext- ciphertext letter pairs?
For decryption, how do you make a decryption matrix given plaintext-ciphertext letter pairs? Also, how do you decrypt when given a key and some ciphertext? Lastly, what if they ask you to produce a decryption matrix given only some plaintext (with number values all arranged in a matrix)? I was asking because at the Regionals test for my school, a couple of Hill Cipher questions where you had to produce A (the other one was THE) decryption matrix showed up, and we had no idea on how to do them.
If you guys could try to help, I would very much appreciate that!
modularmercury wrote:Getting the encryption matrix given letters is pretty easy:CongminhTran wrote:Hey guys,
I was just wondering if any of you guys could help me with the Hill Cipher, both decryption and encryption?
For encryption, how do you make an encryption matrix given plaintext- ciphertext letter pairs?
For decryption, how do you make a decryption matrix given plaintext-ciphertext letter pairs? Also, how do you decrypt when given a key and some ciphertext? Lastly, what if they ask you to produce a decryption matrix given only some plaintext (with number values all arranged in a matrix)? I was asking because at the Regionals test for my school, a couple of Hill Cipher questions where you had to produce A (the other one was THE) decryption matrix showed up, and we had no idea on how to do them.
If you guys could try to help, I would very much appreciate that!
MATH
M A
T H
12 0
19 7
The method for decryption matrix is a little more complicated:
HILL
H I
L L
7 8
11 11
first find the determinant (ad - bc = 7 * 11 - 8 * 11 = -11 = 15 mod 26) and take its multiplicative inverse mod 26 (which would be 7 in this case)
then find the adjugate matrix which is the follwing for a 2 x 2 matrix:
a b
c d
is
d -b
-c a
which would be
11 -8
-11 7
multiply the adjugate matrix by the determinant's inverse and take the values mod 26 to get:
77 -56
-77 49
25 22
1 23
Z W
B X
simple matrix multiplication should confirm, hope this helped and sorry for the formatting
UTF-8 U+6211 U+662F wrote:You might as well just memorize a formula for the inverse matrix
jimmy-bond wrote:UTF-8 U+6211 U+662F wrote:You might as well just memorize a formula for the inverse matrix
One of the tables provided in most tests is the modulo inverso table which goes something like:
1 3 5 7 9 11 15 17 19 21 23 25
1 9 21 15 3 19 7 23 11 5 17 25
(they're supposed to line up)
Instead of using the fractions, we take whatever is opposite on the table of the expression (ad-bc) mod 26.
UTF-8 U+6211 U+662F wrote:[Yes, the fraction should be mod 26, but the formula should still apply ?
mcmn1619 wrote:At regionals, I found a pretty challenging problem that I had no clue how to solve. (weighted the most on the test)
It was a Hill cipher, but instead of giving the encryption matrix or decryption matrix, they gave us 8 letters of plaintext and 8 letters of ciphertext and asked us to solve for the 2x2 encryption matrix.
I only remember the first pair, but the format was something like:
plaintext: WW aw ie ow
encryption: WE wo wi fs
I remember the first pair as WW --> WE because I spent an enormous amount of time looking for patterns in that ([-4,-4] --> [-4, 4] mod 26). All the letters had even indices except for like one or two of them. I feel like I'm just not familiar enough with modular arithmetic to solve the problem. After 40 minutes of cracking (our team managed to get most of the ciphers, and I still solved 2 others), I only knew which letters were even or odd. Any ideas on how to approach something like this?
UTF-8 U+6211 U+662F wrote:mcmn1619 wrote:At regionals, I found a pretty challenging problem that I had no clue how to solve. (weighted the most on the test)
It was a Hill cipher, but instead of giving the encryption matrix or decryption matrix, they gave us 8 letters of plaintext and 8 letters of ciphertext and asked us to solve for the 2x2 encryption matrix.
I only remember the first pair, but the format was something like:
plaintext: WW aw ie ow
encryption: WE wo wi fs
I remember the first pair as WW --> WE because I spent an enormous amount of time looking for patterns in that ([-4,-4] --> [-4, 4] mod 26). All the letters had even indices except for like one or two of them. I feel like I'm just not familiar enough with modular arithmetic to solve the problem. After 40 minutes of cracking (our team managed to get most of the ciphers, and I still solved 2 others), I only knew which letters were even or odd. Any ideas on how to approach something like this?
Warning: I don't do this event, so my knowledge of it is a little shaky.
Convert both plaintext and encryption to a series of matrices. You should have four plaintext matrices and four encryption matrices. The goal is to find a matrix where key * plaintext = encryption. You can do this somewhat algebraically. If you use WW and WE, you get
and assuming the key is
Plug in the other pairs for more equations.
I don't know if there's an easier way, but there might be.
Note: 22 and -4 are equivalent mod 26, but I just find 22 easier to write.
Edit: aghhh forgot that A=0 and not A=1, changed some numbers
rafaelnadal wrote:It takes me 3 hours to finish a 19 question test how do i get faster :,,,,,,,)
also my partners never do anything on the actually test but they seem to get things in practice idk how to help them
i usually end up doing like 5-6 questions and my partners do like one question :,)
advice is appreiciated uwu
we usually split up they do aristocrat/paristrocrat, i do the rest :,) i finish and then try to help them but theres not much time
im better at math so i took affine/hill but should i try splitting it up differently >.< we rly need to get better but idk how to help my partners, and i myself can do all the codes but need to get much faster
Scrambledeggs wrote:Does anybody have good suggestions on patristocrats and baconain with 4 or more different symbols?
Users browsing this forum: No registered users and 3 guests