I know modExp() works cause I tested it already. So, I think the problem is rsa_encypt().

If someone could help me I would appreciate it.

My code compiles and when I try to type in the word for example "The Queen Can't Roll When Sand is in the Jar." It tells me None...

My code so far

p = 61 q = 53 e = 17 n = p * q def rsa_encypt(m, message): c = "" m = "" #make message length even if len(message) % 2 == 1: message += " " for val in message: #pad zeros number = str(aDict[val]) if len(number) < 2: number = "0" + number m += number #encrypt if len(m) == 4: c +=modExp(m,e,n) + "" m = "" return c aDict = { chr(x):x for x in range(129) } def modExp(a, b, m) : """Computes a to the power b, modulo m, using binary exponentiation """ a %= m ret = None if b == 0 : ret = 1 elif b%2 : ret = a * modExp(a,b-1,m) else : ret = modExp(a,b//2,m) ret *= ret return ret%m message = input("ENCRYPT YOUR MESSAGE").lower() print (rsa_encypt(n,message))