FE A Sol
FE A Sol
1) (5 pts) How many possible keys are there for an affine cipher for an alphabet of size 60?
Solution
The affine cipher encryption function takes the form f(x) = (ax + b) mod n, where n is the alphabet
size. b can be any value in between 0 and n-1, and a must be a value in between 0 and n-1 that is
relatively prime with n. There are φ(n) such values. Any valid value of a and be paired with any
valid value of b, so we multiply the # of valid values of each to obtain the number of possible keys
there are, which is
Solution
Since there are 100 total bits y = 100 - x. the index of coincidence of the set is
2𝑥 2 − 200𝑥 + 4200 = 0
𝑥 2 − 100𝑥 + 2100 = 0
(𝑥 − 30)(𝑥 − 70) = 0
Thus, x = 30 or x = 70. If x is 30, y is 70 and vice versa. Either way, |x - y| = |30-70| = 40.
Solution
Here are the corresponding equations for the encryption key, noting that TRIP converts to 19, 17,
8, 15 and TJMP converts to 19, 9, 12, 15, numerically:
𝑎 𝑏 19 19
( ) ( ) = ( ) 𝑚𝑜𝑑 26
𝑐 𝑑 17 9
𝑎 𝑏 8 12
( ) ( ) = ( ) 𝑚𝑜𝑑 26
𝑐 𝑑 15 15
The corresponding sets of equations, we regrouped appropriately (take first equation from both
pairs and put those together and second equation from both pairs and put those together):
Multiply both sets of equations by 15 and 17 respectively and subtract, use a calculator for the
arithmetic:
Look on the modular inverse lookup chart to find that 19-1 mod 26 = 11 and multiply through:
Backsubstitute for
19(7) + 17b ≡ 19 mod 26 19(6) + 17d ≡ 9 mod 26
17b ≡ -114 mod 26 17d ≡ -105 (mod 25)
17b ≡ 16 mod 26, since 17-1 ≡ 23 (mod 26), 17d ≡ 25 (mod 25)
23(17)b ≡ 23*16 mod 26, so b ≡ 4 (mod 26) 23(17)d ≡ 23*25 mod 26, so d ≡ 3 (mod 26)
𝟕 𝟒
Thus, the matrix is ( ).
𝟔 𝟑
Grading: 4 pts for setting up 4 equations, 2 pts to get to isolating (a/b AND c/d), 4 pts for
each of a, b, c, d (1 pt for each)