To solve the Hill Cipher a have setup symbolic equations;
R = IntegerModRing(26)
a,b,c,d,x1,x2 = var('k_1,k_2,k_3,k_4,x1,x2')
K = Matrix(SR,[[a,b],[c,d]]); K
print(K)
pl = vector(SR,[1,29])
ci = vector(SR,[8,21])
eq1,eq2 = (K*pl-ci)
pl = vector(SR,[25,22])
ci = vector(SR,[x1,i])
eq3,eq4 = (K*pl-ci)
pl = vector(SR,[7,16])
ci = vector(SR,[x2,19])
eq5,eq6 = (K*pl-ci)
solve((eq1,eq2,eq3,eq4,eq5,eq6), [a,b,c,d,x1,x2])
There is a problem that The symbolic equations are not working modulo 26. For example, the first equation is
k_1 + 29*k_2 - 8
So how can I properly turn them into modulo 26 and solve the equations in modulo 26?