Write a program in Python that will determine the inverse mod 26 of h.
The naive method for calculating the multiplicative inverse of a mod m is given below:
def modInverse(a, m):
a = a % m
for x in range(1, m):
if a * x % m == 1:
return x
return 1
Instead of this, you may use Euclid's Extended algorithm to find the modular inverse.
Now det(A) = {53 - 817} mod 26 = -121 mod 26 = 9.
Cofactor matrix of A:
5
So A1 = (1/det(A)) X Adj(cofactor(A)) = (1/9) mod 26 = 9 mod 26 = 3.
18 mod 26 5
54 9 2 mod 26 127 15 1 15
So A-1 = mod 26 = 5.
17