Isolating variabel in formula

32 Views Asked by At

I am doing some cryptography programming, and I have to isolate a in the following formula in order to decode some cipher-messages. $${g^a\mod p}=21$$

I am pretty far from implementing the isolation, but I would like to understand how it is done. So if you have a solution, I would appreciate pointers to some material to look into

Edit


It should be noted that p is a prime and g is a primitive root modulo of p

I expect the solution to be done with trial and error, since I am trying to make a brute-force program to find a. p will be a prime between 7 and 23