Skip to main content
The National Cipher Challenge

Reply To: !

A Tale of 2 Secrets Forums T.E.M.P.E.S.T. ! Reply To: !

#113710
the_cryptographer_formerly_known_as_madness
Participant

OK, good.

@AndGiggles, md5(“madness”+PLAINTEXT) = 696ac075f6dbc875fd75fe9483e00254

@Everyone, here are some links to the stuff by Leinster on Galois theory, which is actually and entire on-line course:

https://webhomes.maths.ed.ac.uk/~tl/galois/
https://arxiv.org/abs/2408.07499

And if anyone is interested, here is a Python implementation of GF(25) using the same modulus. The mapping from integers to elements of GF(25) is the stupid one, or the standard one, where you just evaluate the polynomial at the modulus, i.e., p(5).
`
class z5(): # integers modulo 5

def __init__(self,n):
if type(n) == z5:
self.value = n.value
elif type(n) == int:
self.value = n % 5
else:
raise Exception(“invalid initialization of an element of Z/5Z”)

def __str__(self):
return str(self.value)

def __repr__(self):
return self.__str__()

def __eq__(self,other):
if type(other) == int:
return self.value == other
return (self.value == other.value)

def __add__(self,other):
if type(other) == int:
return z5(self.value + other)
return z5(self.value + other.value)

def __neg__(self):
return z5(-self.value)

def __sub__(self,other):
if type(other) == int:
return z5(self.value – other)
return self + (-other)

def __mul__(self,other):
if type(other) == int:
return z5(self.value * other)
return z5(self.value * other.value)

def __invert__(self):
if self.value == 0:
raise Exception(“0 is not invertible in Z/5Z”)
return z5([0,1,3,2,4][self.value])

def __truediv__(self,other):
if type(other) == int:
return self * ~z5(other)
return self * ~other

def __int__(self):
return self.value

class g25():

def __init__(self,a,b): # coefficients of a polynomial over Z/5Z: ax + b
self.coefs = [z5(a),z5(b)]

def __str__(self):
return “(“+str(self.coefs[0])+”,”+str(self.coefs[1])+”)”

def __repr__(self):
return self.__str__()

def __eq__(self,other):
return (self.coefs == other.coefs)

def __add__(self,other):
return g25(self.coefs[0] + other.coefs[0],
self.coefs[1] + other.coefs[1])

def __neg__(self):
return g25(-self.coefs[0],-self.coefs[1])

def __sub__(self,other):
return self + (-other)

def __mul__(self,other):
temp = [self.coefs[0] * other.coefs[0],
self.coefs[0] * other.coefs[1] + self.coefs[1] * other.coefs[0],
self.coefs[1] * other.coefs[1]]
while (temp[0] != 0): # the modulus is x^2 + 4x + 2
temp[0] -= 1
temp[1] -= 4
temp[2] -= 2
return g25(temp[1],temp[2])

def __invert__(self):
if self == g25(0,0):
raise Exception(“0 is not invertible in GF(25)”)
for x in range(5): # the dumb brute-force way every time
for y in range(5):
z = g25(x,y)
if self * z == g25(0,1):
return z

def __truediv__(self,other):
return self * ~other

def __int__(self):
return int(self.coefs[0])*5 + int(self.coefs[1])
`

Report a problem